From patchwork Fri Jun 22 23:35:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liran Alon X-Patchwork-Id: 10483327 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 BF659602CB for ; Fri, 22 Jun 2018 23:36:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4ABC28FAF for ; Fri, 22 Jun 2018 23:36:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 999712906A; Fri, 22 Jun 2018 23:36:51 +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 4FA8629056 for ; Fri, 22 Jun 2018 23:36:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934208AbeFVXgn (ORCPT ); Fri, 22 Jun 2018 19:36:43 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:34570 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934303AbeFVXgW (ORCPT ); Fri, 22 Jun 2018 19:36:22 -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 w5MNYZJ9117467; Fri, 22 Jun 2018 23:36:08 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=olF/iAD8pIsSbl8fbLlxCKtijbredIzAdxfXF1dLBMM=; b=GW0S7SuAikWyK6QaBibge396ghW8aPnW1k+nvA0/53VzW7HogkWU3m27j8irg4Hrw0m4 I8bVQPUn0Ie73YkqUfGuHH+wadcxTWABAC5BHIBikFZntpJuOeXjakgxPeS7M0u56FiO Ba8hXieYTyHXoy2yIUwRUDRFA+vzDUoJKMH86gLDlThkFA15ge7CyGQLmZ+dQa8GcZJI 9Gi/U0aX2gM6eDvS8P9uP614PYW+6E6S/5YhFPPuIACTxxMO/VA24y7cE5NS9ahubVj6 Avj7q2NvmgJuHQkUp/Tx4JiA3rqdKvtOvzetgfJaQ0Vp2dr6b7mOKFLBsxQGJg7L6U1g aw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2jrp8huqfh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jun 2018 23:36:08 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w5MNa8oa015890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jun 2018 23:36:08 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 w5MNa769018553; Fri, 22 Jun 2018 23:36:07 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:07 -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 17/22] KVM: nVMX: Add util to encode a VMCS field by its components Date: Sat, 23 Jun 2018 02:35:17 +0300 Message-Id: <1529710522-28315-18-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=497 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 162e9517faa8..9a0cf93ce8a7 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4527,6 +4527,16 @@ static inline int vmcs_field_readonly(unsigned long field) return (vmcs_field_type(field) == VMCS_FIELD_TYPE_READ_ONLY_DATA); } +static inline unsigned long encode_vmcs_field(enum vmcs_field_width width, + enum vmcs_field_type type, + unsigned short index, + bool high) +{ + WARN_ON(index >= 1u << 9); + index &= (1u << 9) - 1; + return (width << 13) | (type << 10) | (index << 1) | (high ? 1 : 0); +} + static void init_vmcs_shadow_fields(void) { int i, j;