Skip to content

Commit 34b4ed7

Browse files
Binbin Wusean-jc
authored andcommitted
KVM: x86: Add X86EMUL_F_INVLPG and pass it in em_invlpg()
Add an emulation flag X86EMUL_F_INVLPG, which is used to identify an instruction that does TLB invalidation without true memory access. Only invlpg & invlpga implemented in emulator belong to this kind. invlpga doesn't need additional information for emulation. Just pass the flag to em_invlpg(). Linear Address Masking (LAM) and Linear Address Space Separation (LASS) don't apply to addresses that are inputs to TLB invalidation. The flag will be consumed to support LAM/LASS virtualization. Signed-off-by: Binbin Wu <binbin.wu@linux.intel.com> Tested-by: Xuelian Guo <xuelian.guo@intel.com> Link: https://lore.kernel.org/r/20230913124227.12574-5-binbin.wu@linux.intel.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 9053284 commit 34b4ed7

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

arch/x86/kvm/emulate.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3440,8 +3440,10 @@ static int em_invlpg(struct x86_emulate_ctxt *ctxt)
34403440
{
34413441
int rc;
34423442
ulong linear;
3443+
unsigned int max_size;
34433444

3444-
rc = linearize(ctxt, ctxt->src.addr.mem, 1, false, &linear);
3445+
rc = __linearize(ctxt, ctxt->src.addr.mem, &max_size, 1, ctxt->mode,
3446+
&linear, X86EMUL_F_INVLPG);
34453447
if (rc == X86EMUL_CONTINUE)
34463448
ctxt->ops->invlpg(ctxt, linear);
34473449
/* Disable writeback. */

arch/x86/kvm/kvm_emulate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct x86_instruction_info {
9292
#define X86EMUL_F_WRITE BIT(0)
9393
#define X86EMUL_F_FETCH BIT(1)
9494
#define X86EMUL_F_IMPLICIT BIT(2)
95+
#define X86EMUL_F_INVLPG BIT(3)
9596

9697
struct x86_emulate_ops {
9798
void (*vm_bugged)(struct x86_emulate_ctxt *ctxt);

0 commit comments

Comments
 (0)