[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z1gNIRWSMy2w7CYp@intel.com>
Date: Tue, 10 Dec 2024 17:42:57 +0800
From: Chao Gao <chao.gao@...el.com>
To: Binbin Wu <binbin.wu@...ux.intel.com>
CC: <pbonzini@...hat.com>, <seanjc@...gle.com>, <kvm@...r.kernel.org>,
<rick.p.edgecombe@...el.com>, <kai.huang@...el.com>,
<adrian.hunter@...el.com>, <reinette.chatre@...el.com>,
<xiaoyao.li@...el.com>, <tony.lindgren@...ux.intel.com>,
<isaku.yamahata@...el.com>, <yan.y.zhao@...el.com>, <michael.roth@....com>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 6/7] KVM: TDX: Handle TDX PV port I/O hypercall
>+static int tdx_emulate_io(struct kvm_vcpu *vcpu)
>+{
>+ struct x86_emulate_ctxt *ctxt = vcpu->arch.emulate_ctxt;
>+ unsigned long val = 0;
>+ unsigned int port;
>+ int size, ret;
>+ bool write;
..
>+
>+ ++vcpu->stat.io_exits;
>+
>+ size = tdvmcall_a0_read(vcpu);
>+ write = tdvmcall_a1_read(vcpu);
a1 (i.e., R13) should be either 0 or 1. Other values are reserved according to
the GHCI spec. It is not appropriate to cast it to a boolean. For example, if
R13=2, KVM shouldn't treat it as a write request; instead, this request should
be rejected.
>+ port = tdvmcall_a2_read(vcpu);
>+
>+ if (size != 1 && size != 2 && size != 4) {
>+ tdvmcall_set_return_code(vcpu, TDVMCALL_STATUS_INVALID_OPERAND);
>+ return 1;
>+ }
Powered by blists - more mailing lists