mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: isaku.yamahata@intel.com, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: isaku.yamahata@gmail.com, Paolo Bonzini <pbonzini@redhat.com>,
	erdemaktas@google.com, Sean Christopherson <seanjc@google.com>,
	Sagi Shahar <sagis@google.com>,
	David Matlack <dmatlack@google.com>,
	Kai Huang <kai.huang@intel.com>,
	Zhi Wang <zhi.wang.linux@gmail.com>,
	chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com,
	Sean Christopherson <sean.j.christopherson@intel.com>
Subject: Re: [PATCH v15 018/115] KVM: TDX: x86: Add ioctl to get TDX systemwide parameters
Date: Tue, 15 Aug 2023 15:56:58 +0800	[thread overview]
Message-ID: <f7784e00-c3ab-8e6b-b241-c6aaff824944@intel.com> (raw)
In-Reply-To: <e84e0b8e16cf7cd573a8a10a8903689fb9cda713.1690322424.git.isaku.yamahata@intel.com>

On 7/26/2023 6:13 AM, isaku.yamahata@intel.com wrote:
...
> +static int tdx_get_capabilities(struct kvm_tdx_cmd *cmd)
> +{
> +	struct kvm_tdx_capabilities __user *user_caps;
> +	const struct tdsysinfo_struct *tdsysinfo;
> +	struct kvm_tdx_capabilities *caps = NULL;
> +	int ret;

needs to initialize ret to 0; otherwise it returns random value on success.

> +
> +	BUILD_BUG_ON(sizeof(struct kvm_tdx_cpuid_config) !=
> +		     sizeof(struct tdx_cpuid_config));
> +
> +	if (cmd->flags)
> +		return -EINVAL;
> +
> +	tdsysinfo = tdx_get_sysinfo();
> +	if (!tdsysinfo)
> +		return -EOPNOTSUPP;
> +
> +	caps = kmalloc(sizeof(*caps), GFP_KERNEL);
> +	if (!caps)
> +		return -ENOMEM;
> +
> +	user_caps = (void __user *)cmd->data;
> +	if (copy_from_user(caps, user_caps, sizeof(*caps))) {
> +		ret = -EFAULT;
> +		goto out;
> +	}
> +
> +	if (caps->nr_cpuid_configs < tdsysinfo->num_cpuid_config) {
> +		ret = -E2BIG;
> +		goto out;
> +	}
> +
> +	*caps = (struct kvm_tdx_capabilities) {
> +		.attrs_fixed0 = tdsysinfo->attributes_fixed0,
> +		.attrs_fixed1 = tdsysinfo->attributes_fixed1,
> +		.xfam_fixed0 = tdsysinfo->xfam_fixed0,
> +		.xfam_fixed1 = tdsysinfo->xfam_fixed1,
> +		.supported_gpaw = TDX_CAP_GPAW_48 |
> +		(kvm_get_shadow_phys_bits() >= 52 &&
> +		 cpu_has_vmx_ept_5levels()) ? TDX_CAP_GPAW_52 : 0,
> +		.nr_cpuid_configs = tdsysinfo->num_cpuid_config,
> +		.padding = 0,
> +	};
> +
> +	if (copy_to_user(user_caps, caps, sizeof(*caps))) {
> +		ret = -EFAULT;
> +		goto out;
> +	}
> +	if (copy_to_user(user_caps->cpuid_configs, &tdsysinfo->cpuid_configs,
> +			 tdsysinfo->num_cpuid_config *
> +			 sizeof(struct tdx_cpuid_config))) {
> +		ret = -EFAULT;
> +	}
> +
> +out:
> +	/* kfree() accepts NULL. */
> +	kfree(caps);
> +	return ret;
> +}


  reply	other threads:[~2023-08-15  7:58 UTC|newest]

Thread overview: 119+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-25 22:13 [PATCH v15 000/115] KVM TDX basic feature support isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 001/115] KVM: VMX: Move out vmx_x86_ops to 'main.c' to wrap VMX and TDX isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 002/115] KVM: x86/vmx: initialize loaded_vmcss_on_cpu in vmx_hardware_setup() isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 003/115] KVM: x86/vmx: Refactor KVM VMX module init/exit functions isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 004/115] KVM: VMX: Reorder vmx initialization with kvm vendor initialization isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 005/115] KVM: TDX: Initialize the TDX module when loading the KVM intel kernel module isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 006/115] KVM: TDX: Add placeholders for TDX VM/vcpu structure isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 007/115] KVM: TDX: Make TDX VM type supported isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 008/115] [MARKER] The start of TDX KVM patch series: TDX architectural definitions isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 009/115] KVM: TDX: Define " isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 010/115] KVM: TDX: Add TDX "architectural" error codes isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 011/115] KVM: TDX: Add C wrapper functions for SEAMCALLs to the TDX module isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 012/115] KVM: TDX: Retry SEAMCALL on the lack of entropy error isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 013/115] KVM: TDX: Add helper functions to print TDX SEAMCALL error isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 014/115] [MARKER] The start of TDX KVM patch series: TD VM creation/destruction isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 015/115] x86/cpu: Add helper functions to allocate/free TDX private host key id isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 016/115] x86/virt/tdx: Add a helper function to return system wide info about TDX module isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 017/115] KVM: TDX: Add place holder for TDX VM specific mem_enc_op ioctl isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 018/115] KVM: TDX: x86: Add ioctl to get TDX systemwide parameters isaku.yamahata
2023-08-15  7:56   ` Xiaoyao Li [this message]
2023-07-25 22:13 ` [PATCH v15 019/115] KVM: x86, tdx: Make KVM_CAP_MAX_VCPUS backend specific isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 020/115] KVM: TDX: create/destroy VM structure isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 021/115] KVM: TDX: initialize VM with TDX specific parameters isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 022/115] KVM: TDX: Make pmu_intel.c ignore guest TD case isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 023/115] KVM: TDX: Refuse to unplug the last cpu on the package isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 024/115] [MARKER] The start of TDX KVM patch series: TD vcpu creation/destruction isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 025/115] KVM: TDX: allocate/free TDX vcpu structure isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 026/115] KVM: TDX: Do TDX specific vcpu initialization isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 027/115] [MARKER] The start of TDX KVM patch series: KVM MMU GPA shared bits isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 028/115] KVM: x86/mmu: introduce config for PRIVATE KVM MMU isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 029/115] KVM: x86/mmu: Add address conversion functions for TDX shared bit of GPA isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 030/115] [MARKER] The start of TDX KVM patch series: KVM TDP refactoring for TDX isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 031/115] KVM: Allow page-sized MMU caches to be initialized with custom 64-bit values isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 032/115] KVM: x86/mmu: Replace hardcoded value 0 for the initial value for SPTE isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 033/115] KVM: x86/mmu: Allow non-zero value for non-present SPTE and removed SPTE isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 034/115] KVM: x86/mmu: Add Suppress VE bit to shadow_mmio_mask/shadow_present_mask isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 035/115] KVM: x86/mmu: Track shadow MMIO value on a per-VM basis isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 036/115] KVM: x86/mmu: Disallow fast page fault on private GPA isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 037/115] KVM: x86/mmu: Allow per-VM override of the TDP max page level isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 038/115] KVM: VMX: Introduce test mode related to EPT violation VE isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 039/115] [MARKER] The start of TDX KVM patch series: KVM TDP MMU hooks isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 040/115] KVM: x86/mmu: Assume guest MMIOs are shared isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 041/115] KVM: x86/tdp_mmu: Init role member of struct kvm_mmu_page at allocation isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 042/115] KVM: x86/mmu: Add a new is_private member for union kvm_mmu_page_role isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 043/115] KVM: x86/mmu: Add a private pointer to struct kvm_mmu_page isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 044/115] KVM: x86/tdp_mmu: Don't zap private pages for unsupported cases isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 045/115] KVM: x86/tdp_mmu: Sprinkle __must_check isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 046/115] KVM: x86/tdp_mmu: Support TDX private mapping for TDP MMU isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 047/115] [MARKER] The start of TDX KVM patch series: TDX EPT violation isaku.yamahata
2023-07-25 22:13 ` [PATCH v15 048/115] KVM: x86/mmu: TDX: Do not enable page track for TD guest isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 049/115] KVM: VMX: Split out guts of EPT violation to common/exposed function isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 050/115] KVM: VMX: Move setting of EPT MMU masks to common VT-x code isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 051/115] KVM: TDX: Add accessors VMX VMCS helpers isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 052/115] KVM: TDX: Add load_mmu_pgd method for TDX isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 053/115] KVM: TDX: Retry seamcall when TDX_OPERAND_BUSY with operand SEPT isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 054/115] KVM: TDX: Require TDP MMU and mmio caching for TDX isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 055/115] KVM: TDX: TDP MMU TDX support isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 056/115] KVM: TDX: MTRR: implement get_mt_mask() for TDX isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 057/115] [MARKER] The start of TDX KVM patch series: TD finalization isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 058/115] KVM: x86/mmu: Introduce kvm_mmu_map_tdp_page() for use by TDX isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 059/115] KVM: TDX: Create initial guest memory isaku.yamahata
2023-08-15 18:50   ` Sagi Shahar
2023-08-15 23:02     ` Isaku Yamahata
2023-07-25 22:14 ` [PATCH v15 060/115] KVM: TDX: Finalize VM initialization isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 061/115] [MARKER] The start of TDX KVM patch series: TD vcpu enter/exit isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 062/115] KVM: TDX: Add helper assembly function to TDX vcpu isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 063/115] KVM: TDX: Implement TDX vcpu enter/exit path isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 064/115] KVM: TDX: vcpu_run: save/restore host state(host kernel gs) isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 065/115] KVM: TDX: restore host xsave state when exit from the guest TD isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 066/115] KVM: x86: Allow to update cached values in kvm_user_return_msrs w/o wrmsr isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 067/115] KVM: TDX: restore user ret MSRs isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 068/115] KVM: TDX: Add TSX_CTRL msr into uret_msrs list isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 069/115] [MARKER] The start of TDX KVM patch series: TD vcpu exits/interrupts/hypercalls isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 070/115] KVM: TDX: complete interrupts after tdexit isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 071/115] KVM: TDX: restore debug store when TD exit isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 072/115] KVM: TDX: handle vcpu migration over logical processor isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 073/115] KVM: x86: Add a switch_db_regs flag to handle TDX's auto-switched behavior isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 074/115] KVM: TDX: Add support for find pending IRQ in a protected local APIC isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 075/115] KVM: x86: Assume timer IRQ was injected if APIC state is proteced isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 076/115] KVM: TDX: remove use of struct vcpu_vmx from posted_interrupt.c isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 077/115] KVM: TDX: Implement interrupt injection isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 078/115] KVM: TDX: Implements vcpu request_immediate_exit isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 079/115] KVM: TDX: Implement methods to inject NMI isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 080/115] KVM: VMX: Modify NMI and INTR handlers to take intr_info as function argument isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 081/115] KVM: VMX: Move NMI/exception handler to common helper isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 082/115] KVM: x86: Split core of hypercall emulation to helper function isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 083/115] KVM: TDX: Add a place holder to handle TDX VM exit isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 084/115] KVM: TDX: Handle vmentry failure for INTEL TD guest isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 085/115] KVM: TDX: handle EXIT_REASON_OTHER_SMI isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 086/115] KVM: TDX: handle ept violation/misconfig exit isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 087/115] KVM: TDX: handle EXCEPTION_NMI and EXTERNAL_INTERRUPT isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 088/115] KVM: TDX: Handle EXIT_REASON_OTHER_SMI with MSMI isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 089/115] KVM: TDX: Add a place holder for handler of TDX hypercalls (TDG.VP.VMCALL) isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 090/115] KVM: TDX: handle KVM hypercall with TDG.VP.VMCALL isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 091/115] KVM: TDX: Add KVM Exit for TDX TDG.VP.VMCALL isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 092/115] KVM: TDX: Handle TDX PV CPUID hypercall isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 093/115] KVM: TDX: Handle TDX PV HLT hypercall isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 094/115] KVM: TDX: Handle TDX PV port io hypercall isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 095/115] KVM: TDX: Handle TDX PV MMIO hypercall isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 096/115] KVM: TDX: Implement callbacks for MSR operations for TDX isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 097/115] KVM: TDX: Handle TDX PV rdmsr/wrmsr hypercall isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 098/115] KVM: TDX: Handle MSR MTRRCap and MTRRDefType access isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 099/115] KVM: TDX: Handle MSR IA32_FEAT_CTL MSR and IA32_MCG_EXT_CTL isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 100/115] KVM: TDX: Handle TDG.VP.VMCALL<GetTdVmCallInfo> hypercall isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 101/115] KVM: TDX: Silently discard SMI request isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 102/115] KVM: TDX: Silently ignore INIT/SIPI isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 103/115] KVM: TDX: Add methods to ignore accesses to CPU state isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 104/115] KVM: TDX: Add methods to ignore guest instruction emulation isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 105/115] KVM: TDX: Add a method to ignore dirty logging isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 106/115] KVM: TDX: Add methods to ignore VMX preemption timer isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 107/115] KVM: TDX: Add methods to ignore accesses to TSC isaku.yamahata
2023-07-25 22:14 ` [PATCH v15 108/115] KVM: TDX: Ignore setting up mce isaku.yamahata
2023-07-25 22:15 ` [PATCH v15 109/115] KVM: TDX: Add a method to ignore for TDX to ignore hypercall patch isaku.yamahata
2023-07-25 22:15 ` [PATCH v15 110/115] KVM: TDX: Add methods to ignore virtual apic related operation isaku.yamahata
2023-07-25 22:15 ` [PATCH v15 111/115] Documentation/virt/kvm: Document on Trust Domain Extensions(TDX) isaku.yamahata
2023-07-25 22:15 ` [PATCH v15 112/115] KVM: x86: design documentation on TDX support of x86 KVM TDP MMU isaku.yamahata
2023-07-25 22:15 ` [PATCH v15 113/115] RFC: KVM: x86: Add x86 callback to check cpuid isaku.yamahata
2023-07-25 22:15 ` [PATCH v15 114/115] RFC: KVM: x86, TDX: Add check for KVM_SET_CPUID2 isaku.yamahata
2023-07-25 22:15 ` [PATCH v15 115/115] [MARKER] the end of (the first phase of) TDX KVM patch series isaku.yamahata

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=f7784e00-c3ab-8e6b-b241-c6aaff824944@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=chen.bo@intel.com \
    --cc=dmatlack@google.com \
    --cc=erdemaktas@google.com \
    --cc=hang.yuan@intel.com \
    --cc=isaku.yamahata@gmail.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kai.huang@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=sagis@google.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=seanjc@google.com \
    --cc=tina.zhang@intel.com \
    --cc=zhi.wang.linux@gmail.com \
    /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

all inboxes | Powered by JetHome®