From patchwork Fri Mar 4 20:46:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 63615 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp282368lbc; Fri, 4 Mar 2016 12:51:43 -0800 (PST) X-Received: by 10.98.72.218 with SMTP id q87mr15045466pfi.152.1457124702777; Fri, 04 Mar 2016 12:51:42 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lf12si7897788pab.207.2016.03.04.12.51.42; Fri, 04 Mar 2016 12:51:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760240AbcCDUvj (ORCPT + 30 others); Fri, 4 Mar 2016 15:51:39 -0500 Received: from mail-bn1bon0069.outbound.protection.outlook.com ([157.56.111.69]:64651 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759993AbcCDUs7 (ORCPT ); Fri, 4 Mar 2016 15:48:59 -0500 Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=amd.com; Received: from localhost.localdomain (124.121.8.20) by SN1PR12MB0445.namprd12.prod.outlook.com (10.162.105.139) with Microsoft SMTP Server (TLS) id 15.1.415.20; Fri, 4 Mar 2016 20:48:44 +0000 From: Suravee Suthikulpanit To: , , , , , CC: , , , , Suravee Suthikulpanit Subject: [PART1 RFC v2 04/10] svm: clean up V_TPR, V_IRQ, V_INTR_PRIO, and V_INTR_MASKING Date: Fri, 4 Mar 2016 14:46:02 -0600 Message-ID: <1457124368-2025-5-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457124368-2025-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1457124368-2025-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [124.121.8.20] X-ClientProxiedBy: SINPR01CA0045.apcprd01.prod.exchangelabs.com (10.141.109.45) To SN1PR12MB0445.namprd12.prod.outlook.com (25.162.105.139) X-MS-Office365-Filtering-Correlation-Id: da115614-4b85-4d4f-702d-08d3446e6295 X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 2:19AAePkQzeUPiYDO5xeC26tWyc6kDzpnNMfSGEI5vNvhdkgmkXhdMJu5WYAdWNS18oTSVbmY3JzGmZ1neI+DtExoKoFbgnszNve0Jvl8jiSBx47aQAMVVqBERIBSYMwN9Zi/UNFW6mI5KCWrJFR2GgPARMg1JQNnxI+JU0Xse9w7TX9SpZPcBaKbNMDRjCQH; 3:SmpoR/PmujQx4O+enpFkxO2B2xZtiI0blrdaI3q7PbByLBhV9t9fdPNNAPzp7WzXcRws4TAlIRI3TcINnucW+RmMKdXfLoBZG5n+1ftqsli7KSt2cMSE0CE/7uGmAxNd; 25:6RYT5RS1Jk/9vH4lF7opefwDlJJJvG9Kxdqr6XjXD8AZ6VoidlNj1vnz9Cd33HEjTSByYdI0PK99Y5HwKdTEOrcgdma86g4zKupSGZ9Sl9ALA9p1uiK0bLLwBeqvyuvit5FrQcYX9+FiOTCojj1QLKpgsf2mYQRu4QxQH6h4ZTLxjo2ynKgR5yofb3csN/+v0beDk+K/2NMpzULjRzpR+YoDW4vfbMWe2ZE4eQk895f81JLBOwlKvPpvkUFZxa3anYg0G5CCXaTdyiAM9TimIr/HBPSyCi9FTNoDQOruy4StU8pfi358FpTtgGYfmMg1TAY6aIYopn/SzJ2DaiJ5Pg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0445; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0445; 20:D+I2JkrUVcSo6+Xb9ku8w+FntDV8eZbUjluTon5egMreQluF4j/t1eRifgJnWhLsM+7CLFo5J4fBoMyCZ1a9Y8Ljm58Ep/v6k2ksryIREGBokYIMG3NqWNPX1ZBaPppc9OVg+/OvVN5IDXHm5TdsNwSfldt9VrTsswMc6CWQTydISMrLBKj0mLUsxkx0yKmTf5lZihZsqvLFakEzFz+IJDOL+FYz/GmrPJcwRF0hiGN5XCV3iHE9KXWByf9YcV+hnzMCHCC2Mnr9AlHYjVqtimZ2NY4de5nMXraJQ0AYZ3mH7oFSZswZjXaxO+6feOjQGlFAjO48HeEu6kw8AKv6A+ycdClgMk+pGq4CQYvah5HBDsxGupt6P9OFK1ZiulRZfOjooWUQgzYmSoz7QIypwKE2eDKGn2CG2Emo99zOLSPW9hh4VgUPqtG/3UAScaxWxuzyfI5bYtYLmEtL6KW3ZhJTT5ZvSPCcslhMmNWe5z+rFRpyQ6eeD2dLzRRtPCra; 4:wtN/yHNjVakbiscJN1omJVemSAiamjGtSxSKLenOZ7be2xMzjWeBn8VVZ6l/IqpApgSsduQD6sgH+GHJMGqpw6vaNFbSXV6DJz2cOOAgZ1vAaeBvIhpP7EGy6tx1II3xgiHp3SwV6K3Q4uFWR5v+WDZHj/v0/wj3Y/QiIpBKb/EAvhKjjMl3VKO09hdC7lQUpRRoyF2UqRcXWVCoUXAHKe29bfb5zdkUm31M4C00HZRah8Rx8EhftTx291dGGDDwVD4dherzR/xrIv0QN4PfHJ/o2/QjErULdtLkETq1jlZg9EdT/2m/m9VIgU1aaHCnS5WBmhpJW5l+L9MKHlxwO09jl9OBBsXfj3BUuQrSv+wkI4svp8befIGXvcdnBlmH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:SN1PR12MB0445; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0445; X-Forefront-PRVS: 0871917CDA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(77096005)(5001770100001)(87976001)(48376002)(47776003)(229853001)(36756003)(2201001)(66066001)(81166005)(50466002)(2950100001)(5004730100002)(189998001)(40100003)(50226001)(5003940100001)(122386002)(5008740100001)(19580405001)(2906002)(19580395003)(86362001)(4326007)(42186005)(50986999)(6116002)(3846002)(1096002)(92566002)(586003)(76176999)(575784001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0445; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR12MB0445; 23:36WXhwkGfBShp16yWLKhZNz+VK/ThI0G0xbJBG1MZ?= =?us-ascii?Q?smcFcBRBXnjKr94LhEt46T7FReyxK4lPkxs1KJ6Pkh+mpqjc8iDXpvkOz36m?= =?us-ascii?Q?LLguKz7DHWubZjDUuN+40nCWQXzxRLy+T2KBsCQ/sCfAR5d/b3kcxRUQiAUh?= =?us-ascii?Q?WxECklcgLI2JOdIgjHEYQSrFJne1rCTv562kVuH+VKNRvTTvXnBYmOFX/GbX?= =?us-ascii?Q?1zcfa6wGroFV7PNHrVBPK4HR8Y3BvQ8jk+cXCnH6iGyiELnup8L0lyNfxEzy?= =?us-ascii?Q?Vq2MI8GZGveCdvykY+bq8p+YO175hczHsHHOqUWkyaZ2bypasmgBYok0LSzm?= =?us-ascii?Q?eWxf8cWOPpjgl3KTx1m0bYvyn3GTzB2tq2HQZDhMNTu72I3ek+4Wuz/T086h?= =?us-ascii?Q?xE+h7XWABMYyJEvwo+0mFXlA+6ZUtQ4Sd8UJKo68Tv4GKVKUcjzAfZMf3By8?= =?us-ascii?Q?83zhLnDaJFB8keZ7id9vTmh2PgQmuScpktSjEzKwNFzhVFC5lBB13IN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PB6SAaB2nutKAJpzTDPpuLQ43bbVdxMaJDf2fpqsEsHUMQ3tF7b0+YbU+mFLsOuCr0ImNs0mxwnFGBq0wJvbaiKZQghvI/I7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2016 20:48:44.8391 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0445 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suravee Suthikulpanit Now that we have defined the bit field, use them to replace existing macros. This patch should not have functional change. Signed-off-by: Suravee Suthikulpanit --- arch/x86/include/asm/svm.h | 9 --------- arch/x86/kvm/svm.c | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 21 deletions(-) -- 1.9.1 diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index db5d7af..7bb34c9 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -118,18 +118,9 @@ struct __attribute__ ((__packed__)) vmcb_control_area { #define V_TPR_MASK 0x0f -#define V_IRQ_SHIFT 8 -#define V_IRQ_MASK (1 << V_IRQ_SHIFT) - -#define V_INTR_PRIO_SHIFT 16 -#define V_INTR_PRIO_MASK (0x0f << V_INTR_PRIO_SHIFT) - #define V_IGN_TPR_SHIFT 20 #define V_IGN_TPR_MASK (1 << V_IGN_TPR_SHIFT) -#define V_INTR_MASKING_SHIFT 24 -#define V_INTR_MASKING_MASK (1 << V_INTR_MASKING_SHIFT) - #define SVM_INTERRUPT_SHADOW_MASK 1 #define SVM_IOIO_STR_SHIFT 2 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 28f8618..6ab66d0 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1052,7 +1052,7 @@ static void init_vmcb(struct vcpu_svm *svm) control->iopm_base_pa = iopm_base; control->msrpm_base_pa = __pa(svm->msrpm); - control->int_ctl = V_INTR_MASKING_MASK; + control->v_intr_masking = 1; init_seg(&save->es); init_seg(&save->ss); @@ -2316,7 +2316,7 @@ static int nested_svm_vmexit(struct vcpu_svm *svm) /* We always set V_INTR_MASKING and remember the old value in hflags */ if (!(svm->vcpu.arch.hflags & HF_VINTR_MASK)) - nested_vmcb->control.int_ctl &= ~V_INTR_MASKING_MASK; + nested_vmcb->control.v_intr_masking = 0; /* Restore the original control entries */ copy_vmcb_control_area(vmcb, hsave); @@ -2526,8 +2526,9 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) svm->nested.intercept = nested_vmcb->control.intercept; svm_flush_tlb(&svm->vcpu); - svm->vmcb->control.int_ctl = nested_vmcb->control.int_ctl | V_INTR_MASKING_MASK; - if (nested_vmcb->control.int_ctl & V_INTR_MASKING_MASK) + svm->vmcb->control.int_ctl = nested_vmcb->control.int_ctl; + svm->vmcb->control.v_intr_masking = 1; + if (nested_vmcb->control.v_intr_masking) svm->vcpu.arch.hflags |= HF_VINTR_MASK; else svm->vcpu.arch.hflags &= ~HF_VINTR_MASK; @@ -2680,7 +2681,7 @@ static int clgi_interception(struct vcpu_svm *svm) /* After a CLGI no interrupts should come */ svm_clear_vintr(svm); - svm->vmcb->control.int_ctl &= ~V_IRQ_MASK; + svm->vmcb->control.v_irq = 0; mark_dirty(svm->vmcb, VMCB_INTR); @@ -3257,7 +3258,7 @@ static int interrupt_window_interception(struct vcpu_svm *svm) { kvm_make_request(KVM_REQ_EVENT, &svm->vcpu); svm_clear_vintr(svm); - svm->vmcb->control.int_ctl &= ~V_IRQ_MASK; + svm->vmcb->control.v_irq = 0; mark_dirty(svm->vmcb, VMCB_INTR); ++svm->vcpu.stat.irq_window_exits; return 1; @@ -3568,11 +3569,11 @@ static inline void svm_inject_irq(struct vcpu_svm *svm, int irq) { struct vmcb_control_area *control; + control = &svm->vmcb->control; control->int_vector = irq; - control->int_ctl &= ~V_INTR_PRIO_MASK; - control->int_ctl |= V_IRQ_MASK | - ((/*control->int_vector >> 4*/ 0xf) << V_INTR_PRIO_SHIFT); + control->v_intr_prio = 0xf; + control->v_irq = 1; mark_dirty(svm->vmcb, VMCB_INTR); } @@ -3738,7 +3739,7 @@ static inline void sync_cr8_to_lapic(struct kvm_vcpu *vcpu) return; if (!is_cr_intercept(svm, INTERCEPT_CR8_WRITE)) { - int cr8 = svm->vmcb->control.int_ctl & V_TPR_MASK; + int cr8 = svm->vmcb->control.v_tpr & V_TPR_MASK; kvm_set_cr8(vcpu, cr8); } } @@ -3752,8 +3753,7 @@ static inline void sync_lapic_to_cr8(struct kvm_vcpu *vcpu) return; cr8 = kvm_get_cr8(vcpu); - svm->vmcb->control.int_ctl &= ~V_TPR_MASK; - svm->vmcb->control.int_ctl |= cr8 & V_TPR_MASK; + svm->vmcb->control.v_tpr = cr8 & V_TPR_MASK; } static void svm_complete_interrupts(struct vcpu_svm *svm)