[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210415180040.GF6318@zn.tnic>
Date: Thu, 15 Apr 2021 20:00:40 +0200
From: Borislav Petkov <bp@...en8.de>
To: Brijesh Singh <brijesh.singh@....com>
Cc: linux-kernel@...r.kernel.org, x86@...nel.org, kvm@...r.kernel.org,
linux-crypto@...r.kernel.org, ak@...ux.intel.com,
herbert@...dor.apana.org.au, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Joerg Roedel <jroedel@...e.de>,
"H. Peter Anvin" <hpa@...or.com>, Tony Luck <tony.luck@...el.com>,
Dave Hansen <dave.hansen@...el.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Tom Lendacky <thomas.lendacky@....com>,
David Rientjes <rientjes@...gle.com>,
Sean Christopherson <seanjc@...gle.com>
Subject: Re: [RFC Part2 PATCH 03/30] x86: add helper functions for RMPUPDATE
and PSMASH instruction
On Wed, Mar 24, 2021 at 12:04:09PM -0500, Brijesh Singh wrote:
> diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c
> index 06394b6d56b2..7a0138cb3e17 100644
> --- a/arch/x86/mm/mem_encrypt.c
> +++ b/arch/x86/mm/mem_encrypt.c
> @@ -644,3 +644,44 @@ rmpentry_t *lookup_page_in_rmptable(struct page *page, int *level)
> return entry;
> }
> EXPORT_SYMBOL_GPL(lookup_page_in_rmptable);
> +
> +int rmptable_psmash(struct page *page)
psmash() should be enough like all those other wrappers around insns.
> +{
> + unsigned long spa = page_to_pfn(page) << PAGE_SHIFT;
> + int ret;
> +
> + if (!static_branch_unlikely(&snp_enable_key))
> + return -ENXIO;
> +
> + /* Retry if another processor is modifying the RMP entry. */
Also, a comment here should say which binutils version supports the
insn mnemonic so that it can be converted to "psmash" later. Ditto for
rmpupdate below.
Looking at the binutils repo, it looks like since version 2.36.
/me rebuilds objdump...
> + do {
> + asm volatile(".byte 0xF3, 0x0F, 0x01, 0xFF"
> + : "=a"(ret)
> + : "a"(spa)
> + : "memory", "cc");
> + } while (ret == PSMASH_FAIL_INUSE);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(rmptable_psmash);
> +
> +int rmptable_rmpupdate(struct page *page, struct rmpupdate *val)
rmpupdate()
> +{
> + unsigned long spa = page_to_pfn(page) << PAGE_SHIFT;
> + bool flush = true;
> + int ret;
> +
> + if (!static_branch_unlikely(&snp_enable_key))
> + return -ENXIO;
> +
> + /* Retry if another processor is modifying the RMP entry. */
> + do {
> + asm volatile(".byte 0xF2, 0x0F, 0x01, 0xFE"
> + : "=a"(ret)
> + : "a"(spa), "c"((unsigned long)val), "d"(flush)
^^^^^^^^^^^^^^^
what's the cast for?
"d"(flush)?
There's nothing in the APM talking about RMPUPDATE taking an input arg
in %rdx?
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists