From patchwork Fri Jun 22 23:35:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 10483311 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E7BED602CB for ; Fri, 22 Jun 2018 23:36:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6EFC28FAF for ; Fri, 22 Jun 2018 23:36:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBB4429065; Fri, 22 Jun 2018 23:36:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72F1828FAF for ; Fri, 22 Jun 2018 23:36:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934341AbeFVXg1 (ORCPT ); Fri, 22 Jun 2018 19:36:27 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34582 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934209AbeFVXgY (ORCPT ); Fri, 22 Jun 2018 19:36:24 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5MNZNL0118390; Fri, 22 Jun 2018 23:36:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=vemSFJTFLwMhtQS/GCwgH33L7EFxcCZsq7GKPNcGc9Y=; b=gfG+UrBWSHi68YNdULpyUmk+ixOlu3Q+OKm0IMwvqUAAlGD8v36R63ZS1ZohGkmC7gs+ pRcmKkNiQKHy/h4+rv1ztC0ngyeXfz9g4pMPoP7dEFsCcfivuZA+0bKg0EEfucCJJ+HR K/hV5l10EmcHv9q2s/XihOuxl1tMya30IQM3BMmBqge6ZH0LZ+dRWVBWTKteAGC1Sa4S MhSVPLyu/Rb0yBO2kGKaIj+ExkJTLPibwuJIQTH8hY2TPt4Hy0ZmtNa5QJnWmV8wJYtS BYowPqvF+MAUfUMFXuL0JTK1Au+SZsC3/JAbtvHFmWFNneFjMahd4nmHTMLto2BWoLdE 1Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2jrp8huqfk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jun 2018 23:36:11 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5MNa9qg025843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jun 2018 23:36:10 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5MNa9Vx018565; Fri, 22 Jun 2018 23:36:09 GMT Received: from liran-pc.mynet (/79.183.72.72) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 22 Jun 2018 16:36:09 -0700 From: Liran Alon To: pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org Cc: jmattson@google.com, idan.brown@oracle.com, Liran Alon Subject: [PATCH 18/22] KVM: nVMX: Add util to check if VMCS field supported by CPU Date: Sat, 23 Jun 2018 02:35:18 +0300 Message-Id: <1529710522-28315-19-git-send-email-liran.alon@oracle.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1529710522-28315-1-git-send-email-liran.alon@oracle.com> References: <1529710522-28315-1-git-send-email-liran.alon@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8932 signatures=668703 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=755 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1806220260 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Liran Alon Signed-off-by: Jim Mattson --- arch/x86/kvm/vmx.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 9a0cf93ce8a7..72bd4b6a90fc 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2167,6 +2167,19 @@ static __always_inline void vmcs_writel(unsigned long field, unsigned long value __vmcs_writel(field, value); } +static bool cpu_has_vmcs_field(unsigned long field) +{ + unsigned long value; + u8 error; + + asm volatile (__ex_clear(ASM_VMX_VMREAD_RDX_RAX, "%0") "; seta %1" + : "=a"(value), "=qm"(error) + : "d"(field) + : "cc"); + + return error; +} + static __always_inline void vmcs_clear_bits(unsigned long field, u32 mask) { BUILD_BUG_ON_MSG(__builtin_constant_p(field) && ((field) & 0x6000) == 0x2000,