From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by mx.groups.io with SMTP id smtpd.web11.2712.1686121252819009549 for ; Wed, 07 Jun 2023 00:00:52 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@ventanamicro.com header.s=google header.b=IHi1Vqav; spf=pass (domain: ventanamicro.com, ip: 209.85.215.178, mailfrom: tphan@ventanamicro.com) Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-53f9a376f3eso6283214a12.0 for ; Wed, 07 Jun 2023 00:00:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1686121251; x=1688713251; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=gIfOoBy9yeppITnvpxdOXpFhU4SDR2Tez67Jfgidy/g=; b=IHi1Vqav5SaFsKIAKekcTK/aIypIfBIqq51h/aNDuowRGtE/NuiqQP3sICxbpmoo4V mo/ePNp1cwIkXzEnStutWU3vXBXb0jIBtEIOpSF+a6l3KHVtpFu9DhK3Czf7HJ6Ccl1d GiohuY/2NFEKThj6XQtfihFqPb3JLnKHQEhNeSv++rN6kiIUVamQ5Fl3UGhLzeI55IgL 3kwxlbTRCQBTqI0rrEILlxO5HGCAtLobpYHrrE20aMrepNn5JgIJkeJrwOwkFCqx/KwH ArZx/zWR5+5IFTbc3+vJtYetcK2Rp8CeOp+8mqRngp7Y8LsxY/fkd0Tbzmh+3A8qWtKn S+8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686121251; x=1688713251; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gIfOoBy9yeppITnvpxdOXpFhU4SDR2Tez67Jfgidy/g=; b=idKm6uPSd1YHtf/byKShMavB/YEaE015krTVaboZE7/T8IbyH7cwpZPDV4QDKLlW66 E1KDywREvyhzSS5ElRzEweQeC9+oYVsLz9lL6ARgcpa8+st4uvkcW4BZ8ChTiJaGZcVh 4tFuqJyxtvUpr5+c8YF6frffsxnjv36g4Ju6WCC3yk2lIeYlkaJNXdT7EUDQm1bWalVy zZwC+GY8x0dtEzkkffxMvvsU0g5IuKJjjyz0IMArdmdqh/k43WwkuXWVj4ghLfCWYESK BW5zDKZNxrrvlsz2fR2CpWj3Q5NdHD+Sy/uLErv0YhEmtw7fMZa1S8Kiv2tK9QoLkwAZ M+zg== X-Gm-Message-State: AC+VfDy2EDv6XTP6xvWlITM7S+jYxVch2BPdXeZ6gW7mKN+7hbXCHunJ DTMJAA1rl3h2p3fx4oE+gvYlUVutiUgVd2YOfU0TuA== X-Google-Smtp-Source: ACHHUZ7VxHGOk1JD1xeDXQQ/176kV/lhPpW8CMAOvvSYJcDyzR989Wb6L95CrWKDQic2mt/e5MlUCg== X-Received: by 2002:a17:90a:ac10:b0:24e:4b1c:74d2 with SMTP id o16-20020a17090aac1000b0024e4b1c74d2mr4577558pjq.32.1686121251308; Wed, 07 Jun 2023 00:00:51 -0700 (PDT) Return-Path: Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id j22-20020a17090a7e9600b00259b729eea9sm661627pjl.8.2023.06.07.00.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 00:00:50 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: andrei.warkentin@intel.com, sunilvl@ventanamicro.com, Tuan Phan Subject: [PATCH] OvmfPkg: RiscVVirt: Fix wrong checking Pci IO access Date: Tue, 6 Jun 2023 23:08:29 -0700 Message-Id: <20230607060829.4442-1-tphan@ventanamicro.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable RiscV uses memory access for IO and MMIO resources, the address limit is MAX_ADDRESS for both of them. Signed-off-by: Tuan Phan --- OvmfPkg/RiscVVirt/PciCpuIo2Dxe/PciCpuIo2Dxe.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/RiscVVirt/PciCpuIo2Dxe/PciCpuIo2Dxe.c b/OvmfPkg/RiscVV= irt/PciCpuIo2Dxe/PciCpuIo2Dxe.c index f3bf07e63141..75389235d897 100644 --- a/OvmfPkg/RiscVVirt/PciCpuIo2Dxe/PciCpuIo2Dxe.c +++ b/OvmfPkg/RiscVVirt/PciCpuIo2Dxe/PciCpuIo2Dxe.c @@ -19,8 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D #include =0D =0D -#define MAX_IO_PORT_ADDRESS 0xFFFF=0D -=0D //=0D // Handle for the CPU I/O 2 Protocol=0D //=0D @@ -143,16 +141,16 @@ CpuIoCheckParameter ( // Address + Size * Count. If the following condition is met, then the = transfer=0D // is not supported.=0D //=0D - // Address + Size * Count > (MmioOperation ? MAX_ADDRESS : MAX_IO_POR= T_ADDRESS) + 1=0D + // Address + Size * Count > MAX_ADDRESS + 1=0D //=0D // Since MAX_ADDRESS can be the maximum integer value supported by the C= PU and Count=0D // can also be the maximum integer value supported by the CPU, this rang= e=0D // check must be adjusted to avoid all overflow conditions.=0D //=0D // The following form of the range check is equivalent but assumes that= =0D - // MAX_ADDRESS and MAX_IO_PORT_ADDRESS are of the form (2^n - 1).=0D + // MAX_ADDRESS is of the form (2^n - 1).=0D //=0D - Limit =3D (MmioOperation ? MAX_ADDRESS : MAX_IO_PORT_ADDRESS);=0D + Limit =3D MAX_ADDRESS;=0D if (Count =3D=3D 0) {=0D if (Address > Limit) {=0D return EFI_UNSUPPORTED;=0D --=20 2.25.1