Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APLIC register decode doesn't protect against accesses to invalid addresses #12

Open
rrozeTT opened this issue Aug 26, 2024 · 1 comment
Assignees
Labels
aplic APLIC IP related content bug Something isn't working

Comments

@rrozeTT
Copy link

rrozeTT commented Aug 26, 2024

The file aplic_regmap.sv includes logic to decode incoming register transactions. The following block does a check of the incoming register transaction's address ...

    for (int i = 0; i < AplicCfg.NrDomains; i++) begin
        if ((i_req.addr >= AplicCfg.DomainsCfg[i].Addr) && 
            (i_req.addr < (AplicCfg.DomainsCfg[i].Addr + 'h4000 + ('h20 * AplicCfg.NrHarts)))) begin
            
            target_domain = AplicCfg.DomainsCfg[i].id[AplicCfg.NrDomainsW-1:0];
            register_address = i_req.addr - AplicCfg.DomainsCfg[i].Addr;  
            break;
        end
    end

... but there is no handling for the case where an incoming transaction does not fall into any of the valid address ranges. In this scenario, the variables target_domain and register_address will retain their default values of zero.

Later in the same file we process the incoming transaction, using the values for target_domain and register_address that were determined above:

  if (i_req.valid) begin
    if (i_req.write) begin
      unique case(register_address) inside
        'h0: begin
          o_domaincfg[target_domain].dm = AplicCfg.DeliveryMode;

The result here is that incoming register accesses that do not match any of the valid address ranges will still occur, accessing the register at address zero (domaincfg) of the first interrupt domain. This is not good: accessing an invalid address should ideally return zero on reads, and should definitely have no effect on writes.

@D3boker1
Copy link
Member

Hi @rrozeTT ,

I'm sorry for not getting back to you sooner.

Thanks for your comment! We will look into that in the following days, and keep you posted!

@D3boker1 D3boker1 self-assigned this Aug 31, 2024
@D3boker1 D3boker1 added bug Something isn't working aplic APLIC IP related content labels Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aplic APLIC IP related content bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@D3boker1 @rrozeTT and others