From: joeyli <jlee@suse.com>
To: Evgeniy Baskov <baskov@ispras.ru>
Cc: Ard Biesheuvel <ardb@kernel.org>, Borislav Petkov <bp@alien8.de>,
Andy Lutomirski <luto@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Alexey Khoroshilov <khoroshilov@ispras.ru>,
Peter Jones <pjones@redhat.com>,
lvc-project@linuxtesting.org, x86@kernel.org,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH v2 00/23] x86_64: Improvements at compressed kernel stage
Date: Mon, 21 Nov 2022 17:42:06 +0800 [thread overview]
Message-ID: <20221121094206.GA3967@linux-l9pv.suse> (raw)
In-Reply-To: <50aa7df3f34f55ec435c4f489d8f3df3@ispras.ru>
On Sun, Nov 20, 2022 at 06:37:40PM +0300, Evgeniy Baskov wrote:
> On 2022-11-20 04:49, joeyli wrote:
> > Hi Evgeniy,
> >
> > Thanks for your effort!
> >
> > On Tue, Oct 25, 2022 at 05:12:38PM +0300, Evgeniy Baskov wrote:
> ...
> >
> > Because Peter Jones point out this patchset to me, so I tried it
> > on OVMF, and I set the EfiLoaderData in DXE memory protection policy:
> >
> > Index: edk2/MdeModulePkg/MdeModulePkg.dec
> > ===================================================================
> > --- edk2.orig/MdeModulePkg/MdeModulePkg.dec
> > +++ edk2/MdeModulePkg/MdeModulePkg.dec
> > @@ -1392,7 +1392,7 @@
> > # e.g. 0x7BD4 can be used for all memory except Code and
> > ACPINVS/Reserved. <BR>
> > #
> > # @Prompt Set DXE memory protection policy.
> > -
> > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0x0000000|UINT64|0x00001048^M
> > +
> > gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0x0000004|UINT64|0x00001048^M
> >
> > ## PCI Serial Device Info. It is an array of Device, Function, and
> > Power Management
> > # information that describes the path that contains zero or more
> > PCI to PCI bridges
> >
> >
> > I applied this v2 patch set on top of v6.1-rc5 kernel, and boot with a
> > shim which
> > set the PE NX-compatibility DLL Characteristic flag. I got a page
> > fault exception:
> >
> > Loading Linux 6.1.0-rc5-default+ ...
> > Loading initial ramdisk ...
> > !!!! X64 Exception Type - 0E(#PF - Page-Fault) CPU Apic ID - 00000000
> > !!!!
> > ExceptionData - 0000000000000011 I:1 R:0 U:0 W:0 P:1 PK:0 SS:0 SGX:0
> > RIP - 0000000076A3C390, CS - 0000000000000038, RFLAGS -
> > 0000000000210202
> > RAX - 000000007D8CCDF8, RCX - 0000000076A3C390, RDX - 000000007DE86000
> > RBX - 0000000076A3C000, RSP - 000000007FF0D2C8, RBP - 000000007DE86000
> > RSI - 000000007F9EE018, RDI - 000000007DFD1C18
> > R8 - 0000000076A3C000, R9 - 0000000000000190, R10 - 000000007FF1D658
> > R11 - 0000000000000004, R12 - 0000000000000190, R13 - 000000007D8CCE00
> > R14 - 000000007D8C76B4, R15 - 000000007BF0CBD5
> > DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030
> > GS - 0000000000000030, SS - 0000000000000030
> > CR0 - 0000000080010033, CR2 - 0000000076A3C390, CR3 - 000000007FC01000
> > CR4 - 0000000000000668, CR8 - 0000000000000000
> > DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
> > DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400
> > GDTR - 000000007F9DE000 0000000000000047, LDTR - 0000000000000000
> > IDTR - 000000007F2E9018 0000000000000FFF, TR - 0000000000000000
> > FXSAVE_STATE - 000000007FF0CF20
> > !!!! Find image based on IP(0x7BF0BAB5)
> > /mnt/working/source_code-git/edk2/Build/OvmfX64/DEBUG_GCC5/X64/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe/DEBUG/VariableRuntimeDxe.dll
> > (ImageBase=0000000000F40E7C, EntryPoint=0000000000F767B8) !!!!
> >
> >
> > My question is: Can I just set EfiLoaderData in DXE memory protection
> > policy
> > in EDK2/OVMF to test this patchset? Or which platform (virtual or
> > physical)
> > can we use for testing?
> >
> > Thanks a lot!
> > Joey Lee
>
> Hi,
>
> Thank you for testing!
>
> The EDK2 OVMF with adjusted PcdDxeNxMemoryProtectionPolicy
> should work with the kernel itself.
>
Thanks for your information. And yes, I have tested v6.1
kernel with this patch set success by direct booting EFI but
by firmware's EFI boot manager
> As far as I can see from my testing with EDK2 OVMF, this
> #PF occurred inside GRUB code before the first instruction
> of the kernel. You can try using GRUB master branch, where
> allocations are changed to use EfiLoaderCode type and with
> PcdDxeNxMemoryProtectionPolicy=0x0000004 it will still be
> executable.
>
Thanks! We will check new grub2!
Joey Lee
prev parent reply other threads:[~2022-11-21 9:42 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 14:12 [PATCH v2 00/23] x86_64: Improvements at compressed kernel stage Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 01/23] x86/boot: Align vmlinuz sections on page size Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 02/23] x86/build: Remove RWX sections and align on 4KB Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 03/23] x86/boot: Set cr0 to known state in trampoline Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 04/23] x86/boot: Increase boot page table size Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 05/23] x86/boot: Support 4KB pages for identity mapping Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 06/23] x86/boot: Setup memory protection for bzImage code Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 07/23] x86/build: Check W^X of vmlinux during build Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 08/23] x86/boot: Map memory explicitly Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 09/23] x86/boot: Remove mapping from page fault handler Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 10/23] efi/libstub: Move helper function to related file Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 11/23] x86/boot: Make console interface more abstract Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 12/23] x86/boot: Make kernel_add_identity_map() a pointer Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 13/23] x86/boot: Split trampoline and pt init code Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 14/23] x86/boot: Add EFI kernel extraction interface Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 15/23] efi/x86: Support extracting kernel from libstub Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 16/23] x86/boot: Reduce lower limit of physical KASLR Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 17/23] x86/boot: Reduce size of the DOS stub Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 18/23] tools/include: Add simplified version of pe.h Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 19/23] x86/build: Cleanup tools/build.c Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 20/23] x86/build: Make generated PE more spec compliant Evgeniy Baskov
2022-10-25 14:12 ` [PATCH v2 21/23] efi/x86: Explicitly set sections memory attributes Evgeniy Baskov
2022-10-25 14:13 ` [PATCH v2 22/23] efi/libstub: Add memory attribute protocol definitions Evgeniy Baskov
2022-10-25 14:13 ` [PATCH v2 23/23] efi/libstub: Use memory attribute protocol Evgeniy Baskov
2022-11-04 18:21 ` [PATCH v2 00/23] x86_64: Improvements at compressed kernel stage Limonciello, Mario
2022-11-08 7:01 ` Evgeniy Baskov
2022-11-08 18:17 ` Limonciello, Mario
2022-11-08 23:49 ` Evgeniy Baskov
2022-11-20 1:49 ` joeyli
2022-11-20 15:37 ` Evgeniy Baskov
2022-11-21 9:42 ` joeyli [this message]
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-all 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=20221121094206.GA3967@linux-l9pv.suse \
--to=jlee@suse.com \
--cc=ardb@kernel.org \
--cc=baskov@ispras.ru \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=khoroshilov@ispras.ru \
--cc=linux-efi@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pjones@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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