From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=heyi.guo@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 410102243694C for ; Fri, 23 Feb 2018 00:47:56 -0800 (PST) Received: by mail-pl0-x244.google.com with SMTP id w21so4548926plp.11 for ; Fri, 23 Feb 2018 00:53:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yZtA1A2jW8WTfz6GGtR8b/Eimt6mCsZxTmwmmlhp46U=; b=EPPAbSQ74H4+lykyC76reDZaOxU/aLzExXHB5EilITIebYgz++7M3VdQav7ZWELHnU kpaGdK6ufx0ZKR6QjS94EmjezTndhSIeEGYn6WDr4wbj/87ItI4R90s8Sja8j0AQ2G6Q blE3Lq4E+puzlvxOk3TzT1zW+d1GV49WPmRMc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yZtA1A2jW8WTfz6GGtR8b/Eimt6mCsZxTmwmmlhp46U=; b=Yr7HFNQ9XqKI9ihWl6D/nlxXYF4XW7oFluhWHWL0YU+hRIPc/ugerZbtadoybJe5Fz nkshklcJ88t+3+RYCOt9ifrkHFVqgdhR/Z8CIMEYVjnc6fq2pr5KH+VLmvxE4msJy59O 9CTO/TcuZtYa9QEh0gEqcefYsZIVrw1u6Zg0Jq/JR08+vbOxp+91G7X/mguV4oAVXby/ g3RJP3s4/cMfVzwaUMFkHbLTQcf/82Wc5LHF3XzigHlRvIT04jehN1C3DJHVsrpYPE29 W0HjXlwsyMLN2qk+wZZ6+TfYnGk1ak2G04qZg5ykJWmc+6RRYVTEOPJT792WZOzWikie Yyww== X-Gm-Message-State: APf1xPABGKxn0CDcrMH+QJBTryRdUISIvnzPNgnv4t69ZepOFuF5PicD e0B48ek//jrUMS7jOgP5JhI9Y7sKTCo= X-Google-Smtp-Source: AH8x225jOJW5mJksv+s0jYrFk3NL2a0/Xhz5OSKJhLdY/L/Vlun3JHLVYiAvOgv29iJHInW38iMeeA== X-Received: by 2002:a17:902:6e8c:: with SMTP id v12-v6mr1031972plk.424.1519376037336; Fri, 23 Feb 2018 00:53:57 -0800 (PST) Received: from localhost.localdomain ([45.56.152.187]) by smtp.gmail.com with ESMTPSA id j25sm3422694pgn.92.2018.02.23.00.53.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Feb 2018 00:53:56 -0800 (PST) From: Heyi Guo To: edk2-devel@lists.01.org Cc: Heyi Guo , Ruiyu Ni , Ard Biesheuvel , Star Zeng , Eric Dong , Laszlo Ersek , Michael D Kinney Date: Fri, 23 Feb 2018 16:53:28 +0800 Message-Id: <1519376008-110662-4-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519376008-110662-1-git-send-email-heyi.guo@linaro.org> References: <1519376008-110662-1-git-send-email-heyi.guo@linaro.org> Subject: [RFC v3 3/3] MdeModulePkg/PciBus: return CPU address for GetBarAttributes X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Feb 2018 08:47:56 -0000 According to UEFI spec 2.7, PciIo->GetBarAttributes should return host address (CPU view ddress) rather than device address (PCI view address), and device address = host address + address translation offset, so we subtract translation from device address before returning. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Heyi Guo Cc: Ruiyu Ni Cc: Ard Biesheuvel Cc: Star Zeng Cc: Eric Dong Cc: Laszlo Ersek Cc: Michael D Kinney --- MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c index fef3ece..62179eb 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c @@ -1972,6 +1972,10 @@ PciIoGetBarAttributes ( return EFI_UNSUPPORTED; } } + + // According to UEFI spec 2.7, we need return host address for + // PciIo->GetBarAttributes, and host address = device address - translation. + Descriptor->AddrRangeMin -= Descriptor->AddrTranslationOffset; } return EFI_SUCCESS; -- 2.7.4