From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web12.1351.1587668202540895520 for ; Thu, 23 Apr 2020 11:56:42 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=I1s7nJRz; spf=pass (domain: linaro.org, ip: 209.85.128.66, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-wm1-f66.google.com with SMTP id x25so7572703wmc.0 for ; Thu, 23 Apr 2020 11:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=X1SazxHEzSwK5QX7/0Kl+CxGkZlffYETymy+17YWFvQ=; b=I1s7nJRzuUMquKZjLjXK1e6fIUGikGpB3e6g8y4g+sSb0PxaTnd6F1A/xFfsff0Z9+ Ez/qQkwMb/1PpArQxTnGDg3BwWj4ENanC54zl0gRM+LeaeMQpc9/3YCzcNEfn5OSTXVM AuOw6xWxmqyTSW9uu9Y1EZjBMEqw5A51Y7i3FtDPtyGAhbHZPXIQWSDHT07idUQBT4hu NIE2bfbvesw1G2J2ZRNFdOMXnQ/JkV0oEI2ak1eYw6kynrkFN3AWitqkw6gEo5DmEWjG mMGq2PMTauF9KWsr94slg4e+lDnTfgvNkCUIUy/aDedh4goV1METFTrVFnUkF76RexQG rYHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=X1SazxHEzSwK5QX7/0Kl+CxGkZlffYETymy+17YWFvQ=; b=QOkZzlGq6GTCTuY456hra8nk+pYzUXatt/OAUY6ir+msVvXk3YC0+grSajr1JmrDuE FJ81/r1bfI9vc7EyHZeXiRFex18yxCVsKL9PdP6xPc867gYH/W5lZWKdEhNM+R53b55J 05r7TUrSB5K8NwlW01wqlPH+334am+N9TjDpPYt6WgXQI+7L+VPEqIs1bgyYNe5dnZV8 sEgecTj8+F5GycJU/KvHfslhvjOXxzk0OZhnKtvCMgq0s5O1qAzOVaLZpPqvutFslls3 Hjd3vELcv2dj4HEAcqpseOS/2qXkaresoL1c18pScXJlik0S/NL1vrX3BP7y2pUgyqkc zFZg== X-Gm-Message-State: AGi0PuZ28ccVNcA6Fb6upYlj4kY7UQ7dHgh9kPeQY7MV+QoMaXvAkPeS 9hb2dnsoGKk4z6uxl/VcuNea8FllHW8pV6yzMTQLhQ== X-Google-Smtp-Source: APiQypIyanPBCP1L1Xs8T1FQd86Fdls77ODCytMgJfzgCxV1eTblPltBVoI1y//9Rjh14hmcKi1BxkYhOz9ChT8o6/c= X-Received: by 2002:a7b:c306:: with SMTP id k6mr5466398wmj.40.1587668201057; Thu, 23 Apr 2020 11:56:41 -0700 (PDT) MIME-Version: 1.0 References: <1587638612-13056-1-git-send-email-wasim.khan@nxp.com> In-Reply-To: <1587638612-13056-1-git-send-email-wasim.khan@nxp.com> From: "Ard Biesheuvel" Date: Thu, 23 Apr 2020 20:56:30 +0200 Message-ID: Subject: Re: [PATCH] MdeModulePkg/PciHostBridge: Update Mem and PMem Limit Checks To: Wasim Khan Cc: edk2-devel-groups-io , Varun Sethi , "Wu, Hao A" , "Ni, Ray" Content-Type: text/plain; charset="UTF-8" On Thu, 23 Apr 2020 at 12:43, Wasim Khan wrote: > > With Address Translation Support, it is possible and > also correct that Mem and Pmem Limit cross the 4GB boundary. > Update the checks so that Mem/PMem Limit should not cross 4GB > from the Mem/PMem Base address. > > Signed-off-by: Wasim Khan > --- > MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c > index d304fae..9cf7e98 100644 > --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c > +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c > @@ -117,8 +117,8 @@ CreateRootBridge ( > // Make sure Mem and MemAbove4G apertures are valid > // > if (RESOURCE_VALID (&Bridge->Mem)) { > - ASSERT (Bridge->Mem.Limit < SIZE_4GB); > - if (Bridge->Mem.Limit >= SIZE_4GB) { > + ASSERT (Bridge->Mem.Limit < (Bridge->Mem.Base + SIZE_4GB)); > + if (Bridge->Mem.Limit >= (Bridge->Mem.Base + SIZE_4GB)) { > return NULL; > } > } > @@ -129,8 +129,8 @@ CreateRootBridge ( > } > } > if (RESOURCE_VALID (&Bridge->PMem)) { > - ASSERT (Bridge->PMem.Limit < SIZE_4GB); > - if (Bridge->PMem.Limit >= SIZE_4GB) { > + ASSERT (Bridge->PMem.Limit < (Bridge->PMem.Base + SIZE_4GB)); > + if (Bridge->PMem.Limit >= (Bridge->PMem.Base + SIZE_4GB)) { > return NULL; > } > } > -- > 2.7.4 > This is not the right fix. The translation offset should be taken into account for these checks