From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web08.3022.1643435395291646462 for ; Fri, 28 Jan 2022 21:49:56 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: fanjianfeng@byosoft.com.cn) Received: from DESKTOP-M5NI163 ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Sat, 29 Jan 2022 13:49:51 +0800 X-WM-Sender: fanjianfeng@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: fanjianfeng@byosoft.com.cn Date: Sat, 29 Jan 2022 13:49:51 +0800 From: "Jeff Fan" To: "devel@edk2.groups.io" , grao.v80 , "Michael Brown" Cc: "devel@edk2.groups.io" Subject: Re: [edk2-devel] Read SPI BAR offset 0x10 throwing processor exception References: , <735241e7-8ada-0fb0-e035-0a88d0800403@ipxe.org>, X-Priority: 3 X-Has-Attach: no X-Mailer: Foxmail 7.2.20.269[cn] Mime-Version: 1.0 Message-ID: <2022012913495162918430@byosoft.com.cn> Content-Type: multipart/alternative; boundary="----=_001_NextPart511574242677_=----" ------=_001_NextPart511574242677_=---- Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: base64 UmFuZ2EsDQoNCldoYXQncyBDUjIgdmFsdWUgaW4gRXhjZXB0aW9uIGR1bXAgaW5mb3JtYXRpb27v vJ9JdCBob2xkcyB0aGUgYWN0dWFsIGFkZHJlc3Mgb2NjdXJyZWQgUEYgZXhjZXB0aW9uLg0KDQpF eGNlcHRpb25EYXRhIC0gMDAwMDAwMDAwMDAwMDAwMCAgUDowIG1lYW5zIG5vIHBhZ2UgdHJhbnNp dGlvbiBpbiBwYWdlIHRhYmxlLg0KDQpKZWZmDQoNCg0KZmFuamlhbmZlbmdAYnlvc29mdC5jb20u Y24NCiANCkZyb206IFJh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Bjb25maWd1cmF0aW9uIHNwYWNlLiANCiAgSXQgbG9va3MgYXMgdGhvdWdoIHlv dSBhcmUgdHJ5aW5nIHRvIHVzZSBhbiBNTUlPIGFjY2VzcyB0byByZWFkIGZyb20gDQpQQ0kgY29u ZmlndXJhdGlvbiBzcGFjZSwgd2hpY2ggaXMgbm90IGEgdmFsaWQgdGhpbmcgdG8gZG8uDQoNCkkg c3VzcGVjdCB5b3UgbWF5IHdhbnQgdG8gdXNlIEVGSV9QQ0lfSU9fUFJPVE9DT0wuUGNpLlJlYWQo KSBpbnN0ZWFkLg0KDQpIVEgsDQoNCk1pY2hhZWwNCg0K ------=_001_NextPart511574242677_=---- Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ranga,

What's CR2 value in = Exception dump information=EF=BC=9FIt holds the actual address occurred PF = exception.

ExceptionData - 0000000000000000  P:0 means no page = transition in page table.

Jeff

fanjianfeng@byosoft.com.cn
 
Fr= om: Rao G
D= ate: 2022-01-28 21:08
CC: devel
Subject: Re: = [edk2-devel] Read SPI BAR offset 0x10 throwing processor exception
Hi Michael,

SpiInstance->PchSpiB= ase =3D MmPciBase (
              &nb= sp;               DEFAULT_PCI_BUS_NUMBER= _PCH,
                  &nb= sp;           PCI_DEVICE_NUMBER_PCH_SPI,
 =                     &nbs= p;       PCI_FUNCTION_NUMBER_PCH_SPI
     =                     &nbs= p;   );
DEBUG ((DEBUG_INFO, "PchSpiBase at 0x%x\n", SpiInstanc= e->PchSpiBase));
>> returns PchSpiBase as 0xC00FD000 (Bus 0 Dev= 1F Func 0)

ScSpiBar0 =3D MmioRead32 (SpiInstance-= >PchSpiBase + PCI_BASE_ADDRESSREG_OFFSET) & 0xFFFFF000;
>> this should return value at 0xC00FD010

= Hope it appears to be a standard code and accessing through MMIO library sh= ould work

Thanks
Ranga

On Fri, Jan = 28, 2022 at 12:59 PM Michael Brown <mc= b30@ipxe.org> wrote:
On 28/01/2022 12:47, Rao G wrote:
> Attempting to Read SPIBAR 0x10 from BUS 0 Dev 1F Func 5
>
>  >>
> ScSpiBar0 =3D MmioRead32 (SpiInstance->PchSpiBase +
> PCI_BASE_ADDRESSREG_OFFSET) & 0xFFFFF000;
>  >>
>
> The above code is throwing exception
>
> PchSpiBase at 0xC00FD000
> !!!! X64 Exception Type - 0E(#PF - Page-Fault)  CPU Apic ID - 000= 00000 !!!!
> ExceptionData - 0000000000000000  I:0 R:0 U:0 W:0 P:0 PK:0 SS:0 S= GX:0
> RIP  - 00000000771903D0, CS  - 0000000000000038, RFLAGS - 00= 00000000010046
>
>  From the shell the value at offset 0x10 is 0xFE010000
>
> Any clues on why the processor is throwing exception while accessing t= he
> value PchSpiBase+0x10 ?

PCI_BASE_ADDRESSREG_OFFSET is an offset within PCI configuration space.   It looks as though you are trying to use an MMIO access to read from=
PCI configuration space, which is not a valid thing to do.

I suspect you may want to use EFI_PCI_IO_PROTOCOL.Pci.Read() instead.

HTH,

Michael
=20
------=_001_NextPart511574242677_=------