[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240121153702.GAZa06Hvt8b0hQ4LjR@fat_crate.local>
Date: Sun, 21 Jan 2024 16:37:02 +0100
From: Borislav Petkov <bp@...en8.de>
To: Ard Biesheuvel <ardb@...nel.org>
Cc: Kevin Loughlin <kevinloughlin@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>,
Tom Lendacky <thomas.lendacky@....com>,
Michael Kelley <mikelley@...rosoft.com>,
Pankaj Gupta <pankaj.gupta@....com>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Arnd Bergmann <arnd@...db.de>,
Steve Rutherford <srutherford@...gle.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Hou Wenlong <houwenlong.hwl@...group.com>,
Vegard Nossum <vegard.nossum@...cle.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Yuntao Wang <ytcoode@...il.com>,
Wang Jinchao <wangjinchao@...sion.com>,
David Woodhouse <dwmw@...zon.co.uk>,
Brian Gerst <brgerst@...il.com>, Hugh Dickins <hughd@...gle.com>,
Joerg Roedel <jroedel@...e.de>,
Randy Dunlap <rdunlap@...radead.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Dionna Glaze <dionnaglaze@...gle.com>,
Brijesh Singh <brijesh.singh@....com>,
Michael Roth <michael.roth@....com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
linux-coco@...ts.linux.dev, Ashish Kalra <ashish.kalra@....com>,
Andi Kleen <ak@...ux.intel.com>, Adam Dunlap <acdunlap@...gle.com>,
Peter Gonda <pgonda@...gle.com>, Jacob Xu <jacobhxu@...gle.com>,
Sidharth Telang <sidtelang@...gle.com>
Subject: Re: [RFC PATCH v2] x86/sev: enforce RIP-relative accesses in early
SEV/SME code
On Sun, Jan 21, 2024 at 03:12:56PM +0100, Ard Biesheuvel wrote:
> My preliminary conclusion confirms that the SEV code is quite
> problematic in this regard (which is the reason for this patch, so we
> already knew that, of course).
So we can try to improve the situation gradually so that we don't
break current usages.
> TL;DR I think we will need a way to build certain objects with -fPIC
> (as we do in other places and on other architectures), but we should
> add instrumentation to ensure that these issues can be detected at
> build time. The SEV boot code is especially tricky here as very few
> people can even test it,
No worries about that - us, the Google cloud folks, AWS and a bunch of
others are people I could think of who could help out. :-)
> so applying this patch and hoping that the compiler will never
> generate reachable code paths that only work correctly when executed
> via the ordinary kernel virtual mapping is not sufficient.
..
> 1)
> WARNING: modpost: vmlinux: section mismatch in reference:
> startup_64_pi+0x33 (section: .pi.text) -> sme_enable (section:
> .init.text)
sme_enable() is in the 1:1 mapping TU
arch/x86/mm/mem_encrypt_identity.c, see
1cd9c22fee3a ("x86/mm/encrypt: Move page table helpers into separate translation unit")
so might as well move it to .pi.text
The rest below look like they'd need more serious untangling.
Btw, I just had another idea: we could remove -mcmodel=kernel from the
build flags of the whole kernel once -fPIC is enabled so that gcc can be
forced to do rIP-relative addressing.
I'm being told the reason it doesn't allow mcmodel=kernel with -fPIC is
only a matter of removing that check and that it *should* otherwise work
but someone needs to try that. And then there are older gccs which we
cannot fix.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists