From patchwork Fri Feb 12 13:59:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 61846 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp840146lbl; Fri, 12 Feb 2016 06:01:00 -0800 (PST) X-Received: by 10.66.122.97 with SMTP id lr1mr2333534pab.80.1455285659062; Fri, 12 Feb 2016 06:00:59 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fe1si20150953pac.200.2016.02.12.06.00.58; Fri, 12 Feb 2016 06:00:59 -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 S1752878AbcBLOAu (ORCPT + 30 others); Fri, 12 Feb 2016 09:00:50 -0500 Received: from mail-bn1bon0067.outbound.protection.outlook.com ([157.56.111.67]:52660 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752461AbcBLOAn (ORCPT ); Fri, 12 Feb 2016 09:00:43 -0500 Authentication-Results: 8bytes.org; dkim=none (message not signed) header.d=none; 8bytes.org; dmarc=none action=none header.from=amd.com; Received: from localhost.localdomain (124.121.8.20) by BY1PR12MB0440.namprd12.prod.outlook.com (10.162.147.141) with Microsoft SMTP Server (TLS) id 15.1.403.16; Fri, 12 Feb 2016 14:00:32 +0000 From: Suravee Suthikulpanit To: , , , CC: , , , , Suravee Suthikulpanit , Suravee Suthikulpanit Subject: [PART1 RFC 3/9] svm: clean up V_TPR, V_IRQ, V_INTR_PRIO, and V_INTR_MASKING Date: Fri, 12 Feb 2016 20:59:28 +0700 Message-ID: <1455285574-27892-4-git-send-email-suravee.suthikulpanit@amd.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455285574-27892-1-git-send-email-suravee.suthikulpanit@amd.com> References: <1455285574-27892-1-git-send-email-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [124.121.8.20] X-ClientProxiedBy: SG2PR03CA0036.apcprd03.prod.outlook.com (25.160.233.46) To BY1PR12MB0440.namprd12.prod.outlook.com (25.162.147.141) X-MS-Office365-Filtering-Correlation-Id: 417d675f-066e-4d55-cafe-08d333b4e409 X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0440; 2:IrtrTcrozctBHP4pqPY00wi0Pfk+ypvhlGSOxwyUkQdck3wsOYwEHNsSFTOmnL9I3o0+zp1AsrBt4KB1TJFgQlm66bFzGVEeyUYa8w7ghsbn7Gl54dIhAQayq6z5+Rnn5RnTb7AR/AWnfn7FRPirqzSgeaBoQ+W/qb3pURHObON6+ne0iZd5umvqsRWBErOa; 3:OwvyW8OTI6Wo5EUDRw90/NlGlWXL6ah6uRLy3cw93ZqZ4QfCt9WTP3u0qVxKRMHOu8ztg4SLoizRAyVJW/Ha1WyScNTW8HSrrNwgq+6YZi5gQKSi8go+dizeroBRG9GJ; 25:41Zo+tUGGAl6Indr7s0VfdenoLerKKL7e/51CFK3Va7sjdJYeUAVP0MgyShBZujSMHxOmPUBSt5Io5BYFshu4L495Did+tCD/GH4SaLXMSducv7Y1bPwAVCEw07z2lWOccs5o4xje0jZWBU2JNJpAj6GZlXVzhCvXrOH3x/vspv4m2EyzDJzWIwaOX8E43LAVDZwDElnVw0mSDAVEDbvLtMv7aPEevqbiAkWuxAZ7SOwzAVVtZP19oQZsjna2mDxvIPS0Icl0BiIKx3l9te6kP7sU6G10CQpsoJe0f7fIfwz477vAzpG1gLpBWMyLmxA X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR12MB0440; X-Microsoft-Exchange-Diagnostics: 1; BY1PR12MB0440; 20:DiGuU5lO9Qcoqc7Xq08hrIP0Vwjpx6KZYpWiMXmyUaOxz6yG/HcT7Th6GKRL7vuKl/6jYCMz7FCNWFJjHmz8ILeXyCxzb8QukIknwZBDTeCN/u3J93bC5f+BWfJXGhb7aXg44FeDRKQEdjnMZpZJTHAiGUUR2/hICqhMKfgjU4fN3pmqaxx50l742l//gsifbzqCDD8zoeky6tgedeL8kmdlikmyrvaBfBhsox0lYriSdKTFSWpyPpWmZ52n+6nVIdsQ5dPANIpTrinhLL18l6YjXtpMYUtPldulHYjs7e15GSbakKCn9UEAvlooCNtjaPv3kyZDwrJLAnfcOWJtkh7xSv5aCUJF/2lDfgEefPV9z1JGg4lle+WApSmpId2bENP56EMZAGvkQ+OtnD33oFttG0rREFDMh3y76yiKQDPjdZ7bXRNxU4ekZhC1r+ChEBKbI1eFlirkya6cri5VTJg0hkC/2I318AasqEQ3sVnrULlsrEHOXQN6M3QgIngz; 4:XdtyPYdYO9ulu/CiT3teyJNuT+tmH8YtI2uk7jv9ExGGzbAHx6JjlXxgEFxGMXEjd6Izs1BrHncG38c7ufpLnmpeU9iBof6FkN1mxdrTBShqmNDKCg7WLfhLI07qOArTjXse8f3vybNYqxBW233drXPeXGqvPyTltzwTUbAfyIK4+2QusfqN0BAUtxVeA9Zj4pODIDJUrG97X4iG3bxjGO8tzir3duBlhIa+Jrc5rKMv9gayqtqkZQFjbezPZyFqfh2ZXtCXDLLWAIsCaOFNh+U8PAmv6FqITqxoCUUr8DHrpDXDQSZhk3NgLnuffy0MxFZCBg3yInVevxwatQ2ev6tQIhrMXzufCNLCzjL7f5N4uL9TXHCIrnHxuhfdTmG5OJOu7rVhUaKzMFBTo0Fgn4UjsTE/rmpiEuN1LluCy98= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BY1PR12MB0440; BCL:0; PCL:0; RULEID:; SRVR:BY1PR12MB0440; X-Forefront-PRVS: 0850800A29 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(2201001)(36756003)(48376002)(586003)(40100003)(92566002)(3846002)(575784001)(5003940100001)(77096005)(229853001)(2950100001)(19580395003)(19580405001)(6116002)(5004730100002)(189998001)(4326007)(42186005)(66066001)(50226001)(87976001)(5008740100001)(5001770100001)(122386002)(33646002)(50466002)(76176999)(50986999)(86362001)(5001960100002)(47776003)(1096002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR12MB0440; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR12MB0440; 23:x0lwTmDmjI7+HgSdlH4CQsljCRBGZ4oth6JRhGENX?= =?us-ascii?Q?k1wsD44IpEm+NSfL20Cedn3O6FkABBXjtDmLJEXtIGlS9A8oh/lsraOMB+0k?= =?us-ascii?Q?OrwfwFCEvv4qQn2ZXex/vz6y4QsaNvhPxPl3X7J+luKSX7gEENyRJ9sWJdg7?= =?us-ascii?Q?r3Fd7TW+XSpk14EtTID/jYb1jdVKNyjZ+FsNC6HeiNuXbzs+odlRlsqyh899?= =?us-ascii?Q?Jw+xEjSCiTp0yMk8Zvghx4RqKhqXmTdZWeQDP3oz8hp8HHiiHTHEHw0nYjx5?= =?us-ascii?Q?KGW/PP8LoocdvpL2rhjog7Ny/vUFCvpafj274xgu5EjWP28g/iQUE7MqgOHR?= =?us-ascii?Q?C+yw17/NwjY0pk6O5V7g7LzrURhZan3Fr08B35xLJNokoksJG4r7gq6VkxLF?= =?us-ascii?Q?KpQOZ6zB+9Sby4ORy18ifs5OzoTY4xuP5W84ELSLQ9SW775msdIxZnQNMZew?= =?us-ascii?Q?tzg0PhV7AWCZWut9C7J1uPMG/1jrNrZx2QnFv4a7GyQ7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NhfQ814Zw9zFVItnwbltjKjgtFSmr1QBggeRYh2h8IfMxGpCDZOdzkNidu1Rg5+xvfFzalri3MX1MB0sSFAaDVZlubN03nEG/W9E5+rPHE+tOPWrg X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2016 14:00:32.0470 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB0440 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have defined the bitfield, 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 c13a64b..ca185fb 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); @@ -2306,7 +2306,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); @@ -2516,8 +2516,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; @@ -2670,7 +2671,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); @@ -3247,7 +3248,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; @@ -3558,11 +3559,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); } @@ -3728,7 +3729,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); } } @@ -3742,8 +3743,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)