>+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; >+ }