[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <acf1be97-dbc9-2165-e57d-278295c1d6de@amd.com>
Date: Mon, 29 Nov 2021 15:31:52 -0600
From: Tom Lendacky <thomas.lendacky@....com>
To: "Kirill A. Shutemov" <kirill@...temov.name>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Joerg Roedel <jroedel@...e.de>
Cc: Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
Andi Kleen <ak@...ux.intel.com>,
Dave Hansen <dave.hansen@...el.com>,
Sean Christopherson <seanjc@...gle.com>,
Peter Zijlstra <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
Tony Luck <tony.luck@...el.com>
Subject: Re: [PATCHv3 4/4] x86/sev-es: Use insn_decode_mmio() for MMIO
implementation
On 11/3/21 10:45 AM, Kirill A. Shutemov wrote:
> From: "Kirill A. Shutemov" <kirill@...temov.name>
>
> Switch SEV implementation to insn_decode_mmio(). The helper is going
> to be used by TDX too.
>
> No functional changes. It is only build-tested.
>
> Cc: Tom Lendacky <thomas.lendacky@....com>
> Cc: Joerg Roedel <jroedel@...e.de>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
> Reviewed-by: Andi Kleen <ak@...ux.intel.com>
> Reviewed-by: Tony Luck <tony.luck@...el.com>
> ---
> arch/x86/kernel/sev.c | 171 ++++++++++--------------------------------
> 1 file changed, 40 insertions(+), 131 deletions(-)
>
> diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
> index a6895e440bc3..8fea7ea67c67 100644
> --- a/arch/x86/kernel/sev.c
> +++ b/arch/x86/kernel/sev.c
...
> break;
> + case MMIO_READ_ZERO_EXTEND:
> + ret = vc_do_mmio(ghcb, ctxt, bytes, true);
> + if (ret)
> + break;
> +
Can you keep the "/* Zero extend based on operand size */" comment here
much like you do below with the sign extended operation below.
Thanks,
Tom
> + memset(reg_data, 0, insn->opnd_bytes);
> + memcpy(reg_data, ghcb->shared_buffer, bytes);
> + break;
> + case MMIO_READ_SIGN_EXTEND:
> + ret = vc_do_mmio(ghcb, ctxt, bytes, true);
> + if (ret)
> + break;
>
> - /* MOVS instruction */
> - case 0xa4:
> - bytes = 1;
> - fallthrough;
> - case 0xa5:
> - if (!bytes)
> - bytes = insn->opnd_bytes;
> + if (bytes == 1) {
> + u8 *val = (u8 *)ghcb->shared_buffer;
>
> - ret = vc_handle_mmio_movs(ctxt, bytes);
> + sign_byte = (*val & 0x80) ? 0xff : 0x00;
> + } else {
> + u16 *val = (u16 *)ghcb->shared_buffer;
> +
> + sign_byte = (*val & 0x8000) ? 0xff : 0x00;
> + }
> +
> + /* Sign extend based on operand size */
> + memset(reg_data, sign_byte, insn->opnd_bytes);
> + memcpy(reg_data, ghcb->shared_buffer, bytes);
> break;
> - /* Two-Byte Opcodes */
> - case 0x0f:
> - ret = vc_handle_mmio_twobyte_ops(ghcb, ctxt);
> + case MMIO_MOVS:
> + ret = vc_handle_mmio_movs(ctxt, bytes);
> break;
> default:
> ret = ES_UNSUPPORTED;
> + break;
> }
>
> return ret;
>
Powered by blists - more mailing lists