From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBECDC4CED1 for ; Fri, 4 Oct 2019 07:24:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2FDD215EA for ; Fri, 4 Oct 2019 07:24:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="C8du5VMr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2FDD215EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 53DC38E0003; Fri, 4 Oct 2019 03:24:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EEFB6B0005; Fri, 4 Oct 2019 03:24:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 404418E0003; Fri, 4 Oct 2019 03:24:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0123.hostedemail.com [216.40.44.123]) by kanga.kvack.org (Postfix) with ESMTP id 1E6126B0003 for ; Fri, 4 Oct 2019 03:24:25 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id B21E5180AD82F for ; Fri, 4 Oct 2019 07:24:24 +0000 (UTC) X-FDA: 76005264048.13.songs41_7db8f10940c0d X-HE-Tag: songs41_7db8f10940c0d X-Filterd-Recvd-Size: 7316 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Fri, 4 Oct 2019 07:24:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1570173863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:openpgp:openpgp; bh=pbx+rCyRuyCn21y+hMG3H967or+R7JkmlueXXHjswlI=; b=C8du5VMrjjl33LecJPbLOF7zTKeoc2o9uJ5Kd4xlRFsgE3NV/EDTztStybjS1tvQ5MEe9L foM4HvnFYvsKYc6bVb1vO+bkek/RqyTjTacZpRmD8aK6q8O8o0BqnKS3NuPAPaFNmKv0b/ v82Mug/oV7xfwu2b5GcRy6WAEEKx8FU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-220-gmX-6TbnPE6iB4F8DryzGQ-1; Fri, 04 Oct 2019 03:24:20 -0400 Received: by mail-wr1-f70.google.com with SMTP id n3so2303144wrt.9 for ; Fri, 04 Oct 2019 00:24:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=KI34XlCdh0iqJ/GDbHNFKp63Pe8m93EMqaoBoOW2RL4=; b=V5LWpiOAh+CyPprtabOvcCqJvY3T+8GvKkCtDpWiRne6H5iPItecrd0G0yJFOO7e66 zkm0raYu/O8T9KdqTNRNzQAsVD6NKtwQBQlf6x770r7lYIzOL+7QqrjyqICAqlqhIDuy ZcZx07d5KmMaQ11oDXYLTPImjZlxTMoBQcJeEie3VPVCO4oBOp1Lo2mEfwxmznnmzKm1 IJyUYwECrVbOkvUxwm3JsQ1cAlPhfZ+I6mQnVVorhxQ21P44D5rQr6nfBqZ+POYGyFC6 bGW810AGJgwUD7zRRTmdIv4AIy4aERdsbeXD1M1Oze8YSt6zo9gR1aWSb2ghjt9XJNFw g36g== X-Gm-Message-State: APjAAAUIUWQ9gmVRYmnnYbNAGUwbDTpWRnYrJwEsBxejRtzSSnLqQIc/ HTdAEbo2ox5NIK1oR8N9VPreAhud92kRHT1ZNuOD3aTFRaoNWCrDmMDAxdz3xBNnn9o7coRXWbC HffBpAWvusVs= X-Received: by 2002:a1c:a8d8:: with SMTP id r207mr9383060wme.135.1570173859639; Fri, 04 Oct 2019 00:24:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL/3Qg2/nFz5WGI22MgLAEnEVS+FvuTHhN/9hwnbJvJz9GG9hDmIIQ7hOMBhmCec7dUA13VA== X-Received: by 2002:a1c:a8d8:: with SMTP id r207mr9383044wme.135.1570173859354; Fri, 04 Oct 2019 00:24:19 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:e56d:fbdf:8b79:c79c? ([2001:b07:6468:f312:e56d:fbdf:8b79:c79c]) by smtp.gmail.com with ESMTPSA id b16sm5729190wrh.5.2019.10.04.00.24.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Oct 2019 00:24:18 -0700 (PDT) Subject: Re: [RFC PATCH 06/13] kvm: Add KVM_CAP_EXECONLY_MEM To: Rick Edgecombe , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-mm@kvack.org, luto@kernel.org, peterz@infradead.org, dave.hansen@intel.com, sean.j.christopherson@intel.com, keescook@chromium.org Cc: kristen@linux.intel.com, deneen.t.dock@intel.com References: <20191003212400.31130-1-rick.p.edgecombe@intel.com> <20191003212400.31130-7-rick.p.edgecombe@intel.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <0f2307a5-314d-d3df-0bc9-4c1fbbf93f72@redhat.com> Date: Fri, 4 Oct 2019 09:24:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191003212400.31130-7-rick.p.edgecombe@intel.com> Content-Language: en-US X-MC-Unique: gmX-6TbnPE6iB4F8DryzGQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 03/10/19 23:23, Rick Edgecombe wrote: > Add a KVM capability for the KVM_MEM_EXECONLY memslot type. This memslot > type is supported if the HW supports execute-only TDP. >=20 > Signed-off-by: Rick Edgecombe > --- > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/svm.c | 6 ++++++ > arch/x86/kvm/vmx/vmx.c | 1 + > arch/x86/kvm/x86.c | 3 +++ > include/uapi/linux/kvm.h | 1 + > 5 files changed, 12 insertions(+) >=20 > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_h= ost.h > index 6d06c794d720..be3ff71e6227 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1132,6 +1132,7 @@ struct kvm_x86_ops { > =09bool (*xsaves_supported)(void); > =09bool (*umip_emulated)(void); > =09bool (*pt_supported)(void); > +=09bool (*tdp_xo_supported)(void); > =20 > =09int (*check_nested_events)(struct kvm_vcpu *vcpu, bool external_intr)= ; > =09void (*request_immediate_exit)(struct kvm_vcpu *vcpu); > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index e0368076a1ef..f9f25f32e946 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -6005,6 +6005,11 @@ static bool svm_pt_supported(void) > =09return false; > } > =20 > +static bool svm_xo_supported(void) > +{ > +=09return false; > +} > + > static bool svm_has_wbinvd_exit(void) > { > =09return true; > @@ -7293,6 +7298,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_in= it =3D { > =09.xsaves_supported =3D svm_xsaves_supported, > =09.umip_emulated =3D svm_umip_emulated, > =09.pt_supported =3D svm_pt_supported, > +=09.tdp_xo_supported =3D svm_xo_supported, > =20 > =09.set_supported_cpuid =3D svm_set_supported_cpuid, > =20 > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index a30dbab8a2d4..7e7260c715f2 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -7767,6 +7767,7 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_in= it =3D { > =09.xsaves_supported =3D vmx_xsaves_supported, > =09.umip_emulated =3D vmx_umip_emulated, > =09.pt_supported =3D vmx_pt_supported, > +=09.tdp_xo_supported =3D cpu_has_vmx_ept_execute_only, > =20 > =09.request_immediate_exit =3D vmx_request_immediate_exit, > =20 > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2e321d788672..810cfdb1a315 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -3183,6 +3183,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, l= ong ext) > =09=09r =3D kvm_x86_ops->get_nested_state ? > =09=09=09kvm_x86_ops->get_nested_state(NULL, NULL, 0) : 0; > =09=09break; > +=09case KVM_CAP_EXECONLY_MEM: > +=09=09r =3D kvm_x86_ops->tdp_xo_supported(); > +=09=09break; > =09default: > =09=09break; > =09} > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > index ede487b7b216..7778a1f03b78 100644 > --- a/include/uapi/linux/kvm.h > +++ b/include/uapi/linux/kvm.h > @@ -997,6 +997,7 @@ struct kvm_ppc_resize_hpt { > #define KVM_CAP_ARM_PTRAUTH_ADDRESS 171 > #define KVM_CAP_ARM_PTRAUTH_GENERIC 172 > #define KVM_CAP_PMU_EVENT_FILTER 173 > +#define KVM_CAP_EXECONLY_MEM 174 > =20 > #ifdef KVM_CAP_IRQ_ROUTING > =20 >=20 This is not needed, execution only can be a CPUID bit in the hypervisor range (see Documentation/virt/kvm/cpuid.txt). Userspace can use KVM_GET_SUPPORTED_CPUID to check whether the host supports it. Paolo