public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Joerg Roedel <jroedel@suse.de>
Cc: Kuppuswamy Sathyanarayanan 
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Sean Christopherson <seanjc@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Tony Luck <tony.luck@intel.com>
Subject: Re: [PATCHv3 4/4] x86/sev-es: Use insn_decode_mmio() for MMIO implementation
Date: Mon, 29 Nov 2021 15:31:52 -0600	[thread overview]
Message-ID: <acf1be97-dbc9-2165-e57d-278295c1d6de@amd.com> (raw)
In-Reply-To: <20211103154555.23729-5-kirill.shutemov@linux.intel.com>

On 11/3/21 10:45 AM, Kirill A. Shutemov wrote:
> From: "Kirill A. Shutemov" <kirill@shutemov.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@amd.com>
> Cc: Joerg Roedel <jroedel@suse.de>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reviewed-by: Andi Kleen <ak@linux.intel.com>
> Reviewed-by: Tony Luck <tony.luck@intel.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;
> 

  reply	other threads:[~2021-11-29 21:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 15:45 [PATCHv3 0/4] Add generic MMIO instruction deconding to be used in SEV and TDX Kirill A. Shutemov
2021-11-03 15:45 ` [PATCHv3 1/4] x86/insn-eval: Handle insn_get_opcode() failure Kirill A. Shutemov
2021-11-03 15:45 ` [PATCHv3 2/4] x86/insn-eval: Introduce insn_get_modrm_reg_ptr() Kirill A. Shutemov
2021-11-03 15:45 ` [PATCHv3 3/4] x86/insn-eval: Introduce insn_decode_mmio() Kirill A. Shutemov
2021-11-29 21:29   ` Tom Lendacky
2021-11-03 15:45 ` [PATCHv3 4/4] x86/sev-es: Use insn_decode_mmio() for MMIO implementation Kirill A. Shutemov
2021-11-29 21:31   ` Tom Lendacky [this message]
2021-11-30 16:41 ` [PATCHv3 0/4] Add generic MMIO instruction deconding to be used in SEV and TDX Joerg Roedel

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=acf1be97-dbc9-2165-e57d-278295c1d6de@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=ak@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=jroedel@suse.de \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --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