lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87frwrjc0i.ffs@tglx>
Date: Sat, 16 Mar 2024 00:44:45 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: Adam Dunlap <acdunlap@...gle.com>, Ingo Molnar <mingo@...hat.com>,
 Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
 x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>, Nathan Chancellor
 <nathan@...nel.org>, Nick Desaulniers <ndesaulniers@...gle.com>, Bill
 Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>, "Peter
 Zijlstra (Intel)" <peterz@...radead.org>, Arjan van de Ven
 <arjan@...ux.intel.com>, Wei Liu <wei.liu@...nel.org>,
 linux-kernel@...r.kernel.org, llvm@...ts.linux.dev, Jacob Xu
 <jacobhxu@...gle.com>, Alper Gun <alpergun@...gle.com>, Kevin Loughlin
 <kevinloughlin@...gle.com>, Peter Gonda <pgonda@...gle.com>, Ard
 Biesheuvel <ardb@...nel.org>
Cc: Adam Dunlap <acdunlap@...gle.com>
Subject: Re: [PATCH v3] x86/asm: Force native_apic_mem_read to use mov

On Tue, Feb 06 2024 at 14:36, Adam Dunlap wrote:

Can you please use foo() as notation for functions all over the place
including the subject line, which also wants s/mov/the MOV instruction/
and use MOV instead of mov.

> When done from a virtual machine, instructions that touch APIC memory
> must be emulated. By convention, MMIO access are typically performed via
> io.h helpers such as 'readl()' or 'writeq()' to simplify instruction
> emulation/decoding (ex: in KVM hosts and SEV guests) [0].
>
> Currently, native_apic_mem_read does not follow this convention,
> allowing the compiler to emit instructions other than the mov generated
> by readl(). In particular, when compiled with clang and run as a SEV-ES
> or SEV-SNP guest, the compiler would emit a testl instruction which is
> not supported by the SEV-ES emulator, causing a boot failure in that
> environment. It is likely the same problem would happen in a TDX guest
> as that uses the same instruction emulator as SEV-ES.
>
> To make sure all emulators can emulate APIC memory reads via mov, use
> the readl function in native_apic_mem_read. It is expected that any
> emulator would support mov in any addressing mode it is the most generic
> and is what is ususally emitted currently.
>
> The testl instruction is emitted when native_apic_mem_read
> is inlined into __xapic_wait_icr_idle. The emulator comes from
> insn_decode_mmio in arch/x86/lib/insn-eval.c. It would not be worth it

s/It would/It's/

Either it's a fact or not.

> to extend insn_decode_mmio to support more instructions since, in
> theory, the compiler could choose to output nearly any instruction for
> such reads which would bloat the emulator beyond reason.
>
> An alterative to this approach would be to use inline assembly instead
> of the readl helper, as that is what native_apic_mem_write does. I
> consider using readl to be cleaner since it is documented to be a simple
> wrapper and inline assembly is less readable. native_apic_mem_write
> cannot be trivially updated to use writel since it appears to use custom
> asm to workaround for a processor-specific bug.

How is this paragraph relevant?

> [0] https://lore.kernel.org/all/20220405232939.73860-12-kirill.shutemov@linux.intel.com/
>
> Signed-off-by: Adam Dunlap <acdunlap@...gle.com>
> Tested-by: Kevin Loughlin <kevinloughlin@...gle.com>

Other than the above nit picks:

Reviewed-by: Thomas Gleixner <tglx@...utronix.de>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ