Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp51101lqg; Wed, 10 Apr 2024 15:10:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSLio1WIGYwcf+qoCGuLasozH2s7AEgEMAJ0FKNoAZIBuXf0u9nncxS2WBZQYBJMFHq1pUfCaJQKwnzM3VSJlemfnDYUE73cfMmZH9aA== X-Google-Smtp-Source: AGHT+IHFuxudornFac19S5EX2uslXMxqpa9aKRpj6ui/DGlrAvlP0FjS+xJZ+6cxoQmxTcjdO/5b X-Received: by 2002:a17:906:4e81:b0:a52:20cd:39dc with SMTP id v1-20020a1709064e8100b00a5220cd39dcmr15661eju.57.1712787044398; Wed, 10 Apr 2024 15:10:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712787044; cv=pass; d=google.com; s=arc-20160816; b=dit8GE/2Hjlvt2Md8clEcRnBnjyJ+xBqo+9Z8Py7WYGLZJoiwLf+eGuT1qLudg+uNK jz3nV0nJIb3S10iKGbcOIYD/QVKbKeSCOT7hjJnO53anHRr6W1l6xav0oY0K7+zrb21r kQET1DE19WW1WFjU810vtHRAnaas5Vjd6Ih3hFoqynbJ+wT77ETsXPByU9KDRf2MspvH 205LHJOvnQ4Cum7HlPukb1B0NUvyb5Fi4ABjaLMr7HPd1fUYSoHJoylL/7ZhpxkZWFSn hW+lUYQUphaxxVPqqoZEHyv9ekuvPNvk0DT1pUym5sin4d4vYbrTFXA+46LEkiAkh3rP hXpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HfH3pvksEnuL5+tDr2lGfbbplkrtUQO1Vs67wiKJV3c=; fh=6GvjuWek5e/NmuoNTFo6o746VvXwCIN6aC0mGYYr2FM=; b=rsKFYaoR6VAruIEs4o/cmW2qEnh9H7uxwxu4smivw+SmrEtY1hGE9OuJ8agBdvHhCy hCNGAh5WKgWjT/yUvemjljhOldgK8mmzdIXNtPkFPUtwMZvRn1F0PuHz7WM1/c9bwjg5 14bYMs3xNgRYCBZQUex/S/mogCdFJ5LeuK9P04RmM2FM98KJbqLYJqu0i1R/Akk802ST Ca7TaeGzpcctxWo+gqGSIzYJD55qPkF28gxnPXMY5yK5I2/wZKF1FD+UQWG+O8puiG29 JnabappAHqPd+h8m8wYCMzDKrEUx1lWSkS8CkgyhjQ6yxxGptlAU425bEh14fWPKMOA5 YBug==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Jb69LJbo; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-139407-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139407-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id sh35-20020a1709076ea300b00a520a15a9ecsi81176ejc.22.2024.04.10.15.10.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 15:10:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139407-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Jb69LJbo; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-139407-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139407-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2710D1F21DC9 for ; Wed, 10 Apr 2024 22:10:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F6701A0B19; Wed, 10 Apr 2024 22:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Jb69LJbo" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8777F199E99; Wed, 10 Apr 2024 22:08:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712786882; cv=none; b=ApROqmkruDbxqssRzNtcoxeTEZRF38G0guVmqteraBILUalz3qii8uUhMNRqgmhXNnIXDd4jxCRZFxDhSSNa/ud9xedf2jo9unnRBegcq3/OkVOaLOeISdaKFG69hASqdmTGw7Lqpd6ByH7f1AM2hr+4mrolpoLnUBT8lCy5/q4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712786882; c=relaxed/simple; bh=yk0wcqElxl1bqJsocGv0srLS/uJA2TdoHc6rwAmCIaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iQG8HKYJdhoBMNhdEEWa16z9GtzYK88AdHFiJiuK4gYrKt8GtyeCtqoQUoZ7u+47H0y/rVyTcUSl0wyDovvlj50yXqvChK/RGGSco3HPBQsv8ousw4mSkKRqAaZHaUaF0P0wAxPCFUSiUuGG4P2jgSfcfrmu9ebdMG56rcio9EA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Jb69LJbo; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712786881; x=1744322881; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yk0wcqElxl1bqJsocGv0srLS/uJA2TdoHc6rwAmCIaU=; b=Jb69LJboraDal8QeHixShG84J4vaMISGr6u8TtcXK5t3fjh5uRNFIyjO nrS+2M1sO1NY+fY4dB7OZPg7FXlaK3FKOWnmjsBWyYU+iFeMwMe5Px4Za fBw+FlaLTEXSQgRBZBlHRMXqZ5ixV5nibUuTVSm9u4IAHUriWl1BxgCSl pM3iSEgOl1qdyPYve4gvIvH0oXr3R/hwqLCAcQzuXwKu49FrCe+Shtb6g jInJQd3tRaKVpX0eigvYvZnlhWYvh18yzi/SZCtXbBgFKuNif2kGxbrx+ ih2zW1d8/xGE+KFWlm7aQT4aEXWCqg0qaLDP8MasPrdAq6eo98wgnoIQ8 g==; X-CSE-ConnectionGUID: psBFvCCWRbWin35ceodU+Q== X-CSE-MsgGUID: NyO7iItHR/W8LPrT7Usivg== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8041154" X-IronPort-AV: E=Sophos;i="6.07,191,1708416000"; d="scan'208";a="8041154" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 15:07:59 -0700 X-CSE-ConnectionGUID: 7qyOBPlMSYuFbrYpFg10Yw== X-CSE-MsgGUID: 46U7rv4GQBqzVjzELZQD5w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,191,1708416000"; d="scan'208";a="25476327" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 15:07:58 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, linux-kernel@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Michael Roth , David Matlack , Federico Parola , Kai Huang Subject: [PATCH v2 09/10] KVM: SVM: Implement pre_mmu_map_page() to refuse KVM_MAP_MEMORY Date: Wed, 10 Apr 2024 15:07:35 -0700 Message-ID: X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Isaku Yamahata Implement vendor callback for KVM_MAP_MEMORY for SEV as EOPNOTSUPP because it should use SEV-specific ioctl instead. This patch is only to demonstrate how to implement the hook. Compile only tested. I leave the actual implementation to the SEV folks. Signed-off-by: Isaku Yamahata --- v2: - Newly added --- arch/x86/kvm/svm/sev.c | 6 ++++++ arch/x86/kvm/svm/svm.c | 2 ++ arch/x86/kvm/svm/svm.h | 9 +++++++++ 3 files changed, 17 insertions(+) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 1642d7d49bde..ab17d7c16636 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -3322,3 +3322,9 @@ struct page *snp_safe_alloc_page(struct kvm_vcpu *vcpu) return p; } + +int sev_pre_mmu_map_page(struct kvm_vcpu *vcpu, + struct kvm_memory_mapping *mapping, u64 *error_code) +{ + return -EOPNOTSUPP; +} diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 535018f152a3..a886d4409b00 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -5057,6 +5057,8 @@ static struct kvm_x86_ops svm_x86_ops __initdata = { .vcpu_deliver_sipi_vector = svm_vcpu_deliver_sipi_vector, .vcpu_get_apicv_inhibit_reasons = avic_vcpu_get_apicv_inhibit_reasons, .alloc_apic_backing_page = svm_alloc_apic_backing_page, + + .pre_mmu_map_page = sev_pre_mmu_map_page, }; /* diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 323901782547..c8dafcb0bfc6 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -689,6 +689,9 @@ int sev_mem_enc_unregister_region(struct kvm *kvm, int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd); int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd); void sev_guest_memory_reclaimed(struct kvm *kvm); +int sev_pre_mmu_map_page(struct kvm_vcpu *vcpu, + struct kvm_memory_mapping *mapping, u64 *error_code); + int sev_handle_vmgexit(struct kvm_vcpu *vcpu); /* These symbols are used in common code and are stubbed below. */ @@ -713,6 +716,12 @@ static inline void __init sev_hardware_setup(void) {} static inline void sev_hardware_unsetup(void) {} static inline int sev_cpu_init(struct svm_cpu_data *sd) { return 0; } static inline int sev_dev_get_attr(u32 group, u64 attr, u64 *val) { return -ENXIO; } +static inline int sev_pre_mmu_map_page(struct kvm_vcpu *vcpu, + struct kvm_memory_mapping *mapping, + u64 *error_code) +{ + return -EOPNOTSUPP; +} #define max_sev_asid 0 #endif -- 2.43.2