public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Fan, Jeff" <jeff.fan@intel.com>
To: Anthony PERARD <anthony.perard@citrix.com>,
	"Yao, Jiewen" <jiewen.yao@intel.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Subject: Re: [PATCH V4 1/3] UefiCpuPkg/CpuDxe: Add memory attribute setting.
Date: Fri, 10 Mar 2017 01:02:22 +0000	[thread overview]
Message-ID: <542CF652F8836A4AB8DBFAAD40ED192A4C559F60@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20170309115237.GK1760@perard.uk.xensource.com>

Anthony,

MSR 0x1A0 is architectural MSR defined in IA32 SDM.

Have you tried AMD real platform?

Thanks!
Jeff

-----Original Message-----
From: Anthony PERARD [mailto:anthony.perard@citrix.com] 
Sent: Thursday, March 09, 2017 7:53 PM
To: Yao, Jiewen
Cc: edk2-devel@lists.01.org; Kinney, Michael D; Fan, Jeff
Subject: Re: [edk2] [PATCH V4 1/3] UefiCpuPkg/CpuDxe: Add memory attribute setting.

On Tue, Feb 21, 2017 at 02:57:07PM +0800, Jiewen Yao wrote:
> Add memory attribute setting in CpuArch protocol.
> Previous SetMemoryAttributes() API only supports cache attribute setting.
> 
> This patch updated SetMemoryAttributes() API to support memory 
> attribute setting by updating CPU page table.
> 
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Michael Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>

Hi,

This patch doesn't work on AMD (when running OVMF on Xen). With an AMD cpu, reading MSR 0x1a0 cause a General Protection Fault.

> +  AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);  if (RegEax > 
> + 0x80000000) {
> +    AsmCpuid (0x80000001, NULL, NULL, NULL, &RegEdx);
> +    if ((RegEdx & BIT20) != 0) {
> +      // XD supported

This next read is where the fault is taken.

> +      if ((AsmReadMsr64 (0x000001A0) & BIT34) == 0) {
> +        // XD enabled
> +        if ((AsmReadMsr64 (0xC0000080) & BIT11) != 0) {
> +          // XD activated
> +          PagingContext->ContextData.Ia32.Attributes |= PAGE_TABLE_LIB_PAGING_CONTEXT_IA32_X64_ATTRIBUTES_XD_ACTIVATED;
> +        }
> +      }
> +    }

>From OVMF output:

!!!! X64 Exception Type - 0D(#GP - General Protection)  CPU Apic ID - 00000000 !!!!
RIP  - 000000002F323ABE, CS  - 0000000000000018, RFLAGS - 0000000000010002 ExceptionData - 0000000000000000 RAX  - 0000000080000001, RCX - 00000000000001A0, RDX - 000000002FD3FBFF RBX  - 000000002F422CB8, RSP - 000000002F422C68, RBP - 000000002EE0AD98 RSI  - 000000002F3AF018, RDI - 000000002F3229E4
R8   - 0000000000000000, R9  - 0000000000000000, R10 - 0000000000000000
R11  - 000000002F422BAD, R12 - 0000000000000000, R13 - 0000000000000000
R14  - 0000000000000000, R15 - 000000002F44A980
DS   - 0000000000000008, ES  - 0000000000000008, FS  - 0000000000000008
GS   - 0000000000000008, SS  - 0000000000000008
CR0  - 00000000C0010033, CR2 - 0000000000000000, CR3 - 000000002F3C1000
CR4  - 0000000000000668, CR8 - 0000000000000000
DR0  - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3  - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400 GDTR - 00000000FFFFFF80 000000000000001F, LDTR - 0000000000000000
IDTR - 000000002B68DD90 000000000000021F,   TR - 0000000000000000
FXSAVE_STATE - 000000002F4228C0
!!!! Find PE image /home/osstest/build.106538.build-amd64/xen/tools/firmware/ovmf-dir-remote/Build/OvmfX64/DEBUG_GCC49/X64/UefiCpuPkg/CpuDxe/CpuDxe/DEBUG/CpuDxe.dll (ImageBase=000000002F321000, EntryPoint=000000002F321271) !!!!


Thanks,

--
Anthony PERARD


  reply	other threads:[~2017-03-10  1:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21  6:57 [PATCH V4 0/3] DXE Memory Protection Jiewen Yao
2017-02-21  6:57 ` [PATCH V4 1/3] UefiCpuPkg/CpuDxe: Add memory attribute setting Jiewen Yao
2017-03-09 11:52   ` Anthony PERARD
2017-03-10  1:02     ` Fan, Jeff [this message]
2017-03-10 15:21       ` Anthony PERARD
2017-03-13  1:58         ` Fan, Jeff
2017-02-21  6:57 ` [PATCH V4 2/3] MdeModulePkg/dec: add PcdImageProtectionPolicy Jiewen Yao
2017-02-21  6:57 ` [PATCH V4 3/3] MdeModulePkg/DxeCore: Add UEFI image protection Jiewen Yao
2017-02-21  7:23 ` [PATCH V4 0/3] DXE Memory Protection Fan, Jeff
2017-02-21  8:36 ` Ard Biesheuvel
2017-02-21  8:39   ` Yao, Jiewen
2017-02-21 17:25     ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=542CF652F8836A4AB8DBFAAD40ED192A4C559F60@shsmsx102.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox