From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08C56330D34 for ; Tue, 30 Jun 2026 22:26:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782858384; cv=none; b=exXPfrVqyHgOh/xU7NWTd1z70v9LfwdNfwv71U5izUP1zEsPPdh5ygacuky79Av+C8hLAXnCu60oGlB+74/JP8B2fb6RPILK4K7Blf2m6KoeN+CrhYItbTjjNUfAAn5w26AlqLd1TXisnwRxz8jQTPcGY5tPxGVleOgNx0a8hzo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782858384; c=relaxed/simple; bh=E9ihg4CHtc058MnIOzPCbYMNOhGQmD9c54Rla5v86N8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fnE6lTTACpO77F+9SNfGOf+wvgN+g2L6y7yD6rTIyGXpI4Khayfk7T5Y8q/TIWuo9Z9sXr9OUD76s8sGG8/Y1jtBcA1xZWZ+zlnMtkLrPau/Taq0ta5XKzjIASGPo9FdZfJnZU8im/gF5hg1cPHPrzfhy6z4srrl5aPdNfgqFFo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VFQdX5Ui; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VFQdX5Ui" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-38096521198so90021a91.3 for ; Tue, 30 Jun 2026 15:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782858381; x=1783463181; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=tgBpkd6omwsYzKK6kftzN/wsFiku2LUumiGt5apq1+o=; b=VFQdX5Ui8g6u2jazSVpwznpByc/pmTgLvEhwSIejBn6wNRxcHYWYeDK7AscuXIc99s J/aJnZvl3jrorqZhWaiaT0maJEvZXk1+ZHC2c7oPIQdLGE+RWGQwu7kVrNmew+zNC6ts EMpf7+tzYZ36QJTaWwkfzs0Y+G0+FG/aCQ57HBHxOhDjojpP9rFEPbfEgQ6afOgt9R8W RZ1mrsbV9mW+jYi/NcUAjHFyHS3eZJ1kgAa2qijYAlpfFrunm7ynH2PnPRWUdlnH4FPT BSZJLFgG0OtZs7+EW30e/BjS/dVCi50Ar8LTOn1PGYOvVmtz93wq/y4a5WVZ9z2/9veT Nkgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782858381; x=1783463181; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tgBpkd6omwsYzKK6kftzN/wsFiku2LUumiGt5apq1+o=; b=W1Nlop3g3MG+PSx5xaB1q7VHkUbsD3QY6mCBTkT7BetmlQZxem0IcYKeHPbWPYILm4 fbsheaEGaF5AV9i7MbKgfzVaip0FgDgs0yZ6LIN0VMTeizCZcGC1FrruShvztw0iM46s M9fBx2RIsAJMSdFIYiOT3Xt32OEDqmvp7O/Js2yyHFP6jcV1LaX33iyEdVEatf+zWcq1 3mB0y/TZc4HaVfbOeYdg9YNnhz0Baw5IQzkNIXaZFocOQt+xdMVN2FRRfyBFDZEIxl/1 5eJGwnZ9eeKCzKSaZ7fNjWFW9df7B7vLKEuYCyrBUPSqffegmKAlcW5Ihm8RpCFGOWpz BSfg== X-Forwarded-Encrypted: i=1; AHgh+RpybWAjUr+9aoIhEvyua50eF9BkJ1O61OjRsGiUGcceSxxTpnZlAw4SsT/2RZIRBFYi+7ToJwnUys07ZKk=@vger.kernel.org X-Gm-Message-State: AOJu0YzR0MpZRYrtRK35oC5z6CR3GvQiqaiokjHvVyTx8FbT8JkGoSik r09Hw4jZg+1ivu/E6ng2lNXllAe2iBuHr8t8dJctqGWPzzWZLDkQh+mpojnINbDkB67wYGOrF0h o7wTL8w== X-Received: from pjbbb9.prod.google.com ([2002:a17:90b:89:b0:37e:2497:f36c]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5241:b0:35f:b987:4dac with SMTP id 98e67ed59e1d1-3808bd6a8a3mr1932999a91.12.1782858380975; Tue, 30 Jun 2026 15:26:20 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 30 Jun 2026 15:26:06 -0700 In-Reply-To: <20260630222607.497895-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260630222607.497895-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog Message-ID: <20260630222607.497895-12-seanjc@google.com> Subject: [PATCH v3 11/12] KVM: x86: Guard .gmem_prepare() declarations with HAVE_KVM_GMEM_PREPARE=y From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ackerley Tng , Hyunwoo Kim , Tom Lendacky , Michael Roth , "=?UTF-8?q?J=C3=B6rg=20R=C3=B6del?=" , Fuad Tabba Content-Type: text/plain; charset="UTF-8" Wrap the .gmem_prepare() declarations with HAVE_KVM_GMEM_PREPARE so that non-SEV code doesn't try to wire up a callback without doing the necessary enabling. No functional change intended. Fixes: 3bb2531e20bf ("KVM: guest_memfd: Add hook for initializing memory") Signed-off-by: Sean Christopherson --- arch/x86/include/asm/kvm-x86-ops.h | 4 +++- arch/x86/include/asm/kvm_host.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h index deb3ded5796e..39247d2f29d6 100644 --- a/arch/x86/include/asm/kvm-x86-ops.h +++ b/arch/x86/include/asm/kvm-x86-ops.h @@ -146,12 +146,14 @@ KVM_X86_OP(vcpu_deliver_sipi_vector) KVM_X86_OP_OPTIONAL_RET0(vcpu_get_apicv_inhibit_reasons); KVM_X86_OP_OPTIONAL(get_untagged_addr) KVM_X86_OP_OPTIONAL(alloc_apic_backing_page) +#ifdef CONFIG_HAVE_KVM_ARCH_GMEM_PREPARE KVM_X86_OP_OPTIONAL_RET0(gmem_prepare) -KVM_X86_OP_OPTIONAL_RET0(gmem_max_mapping_level) +#endif #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_INVALIDATE KVM_X86_OP_OPTIONAL(gmem_invalidate_range) KVM_X86_OP_OPTIONAL(gmem_reclaim_memory) #endif +KVM_X86_OP_OPTIONAL_RET0(gmem_max_mapping_level) #endif #undef KVM_X86_OP diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 93af3bb82869..cf2ec19212ad 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1903,7 +1903,9 @@ struct kvm_x86_ops { gva_t (*get_untagged_addr)(struct kvm_vcpu *vcpu, gva_t gva, unsigned int flags); void *(*alloc_apic_backing_page)(struct kvm_vcpu *vcpu); +#ifdef CONFIG_HAVE_KVM_ARCH_GMEM_PREPARE int (*gmem_prepare)(struct kvm *kvm, kvm_pfn_t pfn, gfn_t gfn, int max_order); +#endif #ifdef CONFIG_HAVE_KVM_ARCH_GMEM_INVALIDATE void (*gmem_invalidate_range)(struct kvm *kvm, struct kvm_gfn_range *range); void (*gmem_reclaim_memory)(kvm_pfn_t start, kvm_pfn_t end); -- 2.55.0.rc0.799.gd6f94ed593-goog