From patchwork Thu Mar 24 11:29:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8660091 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9CDF89F44D for ; Thu, 24 Mar 2016 11:32:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DD7920382 for ; Thu, 24 Mar 2016 11:32:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7A112034F for ; Thu, 24 Mar 2016 11:32:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj3SK-0005sU-GU; Thu, 24 Mar 2016 11:29:36 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj3SJ-0005sH-P4 for xen-devel@lists.xenproject.org; Thu, 24 Mar 2016 11:29:35 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 07/E3-29237-F9FC3F65; Thu, 24 Mar 2016 11:29:35 +0000 X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1458818972!5806995!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56195 invoked from network); 24 Mar 2016 11:29:34 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-7.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 24 Mar 2016 11:29:34 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 24 Mar 2016 05:29:32 -0600 Message-Id: <56F3DDAC02000078000E0083@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Thu, 24 Mar 2016 05:29:32 -0600 From: "Jan Beulich" To: "xen-devel" References: <56F3DBC502000078000E0060@prv-mh.provo.novell.com> In-Reply-To: <56F3DBC502000078000E0060@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper , Paul Durrant , Keir Fraser Subject: [Xen-devel] [PATCH 2/3] x86/vLAPIC: vlapic_reg_write() can't fail X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It only ever returns X86EMUL_OKAY, so to make this more obvious change the function return type to void. Re-structure vlapic_apicv_write() at once to have only a single path leading to vlapic_reg_write(). Signed-off-by: Jan Beulich x86/vLAPIC: vlapic_reg_write() can't fail It only ever returns X86EMUL_OKAY, so to make this more obvious change the function return type to void. Re-structure vlapic_apicv_write() at once to have only a single path leading to vlapic_reg_write(). Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -681,11 +681,10 @@ static void vlapic_tdt_pt_cb(struct vcpu vcpu_vlapic(v)->hw.tdt_msr = 0; } -static int vlapic_reg_write(struct vcpu *v, - unsigned int offset, uint32_t val) +static void vlapic_reg_write(struct vcpu *v, + unsigned int offset, uint32_t val) { struct vlapic *vlapic = vcpu_vlapic(v); - int rc = X86EMUL_OKAY; memset(&vlapic->loaded, 0, sizeof(vlapic->loaded)); @@ -815,14 +814,7 @@ static int vlapic_reg_write(struct vcpu HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER, "timer divisor is %#x", vlapic->hw.timer_divisor); break; - - default: - break; } - if (rc == X86EMUL_UNHANDLEABLE) - gdprintk(XENLOG_DEBUG, - "Local APIC Write wrong to register %#x\n", offset); - return rc; } static int vlapic_write(struct vcpu *v, unsigned long address, @@ -871,7 +863,9 @@ static int vlapic_write(struct vcpu *v, else if ( unlikely(offset & 3) ) goto unaligned_exit_and_crash; - return vlapic_reg_write(v, offset, val); + vlapic_reg_write(v, offset, val); + + return X86EMUL_OKAY; unaligned_exit_and_crash: gprintk(XENLOG_ERR, "Unaligned LAPIC write: len=%u offset=%#x.\n", @@ -886,14 +880,18 @@ int vlapic_apicv_write(struct vcpu *v, u struct vlapic *vlapic = vcpu_vlapic(v); uint32_t val = vlapic_get_reg(vlapic, offset); - if ( !vlapic_x2apic_mode(vlapic) ) - return vlapic_reg_write(v, offset, val); + if ( vlapic_x2apic_mode(vlapic) ) + { + if ( offset != APIC_SELF_IPI ) + return X86EMUL_UNHANDLEABLE; - if ( offset != APIC_SELF_IPI ) - return X86EMUL_UNHANDLEABLE; + offset = APIC_ICR; + val = APIC_DEST_SELF | (val & APIC_VECTOR_MASK); + } + + vlapic_reg_write(v, offset, val); - return vlapic_reg_write(v, APIC_ICR, - APIC_DEST_SELF | (val & APIC_VECTOR_MASK)); + return X86EMUL_OKAY; } int hvm_x2apic_msr_write(struct vcpu *v, unsigned int msr, uint64_t msr_content) @@ -971,7 +969,9 @@ int hvm_x2apic_msr_write(struct vcpu *v, return X86EMUL_UNHANDLEABLE; } - return vlapic_reg_write(v, offset, msr_content); + vlapic_reg_write(v, offset, msr_content); + + return X86EMUL_OKAY; } static int vlapic_range(struct vcpu *v, unsigned long addr) Reviewed-by: Andrew Cooper --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -681,11 +681,10 @@ static void vlapic_tdt_pt_cb(struct vcpu vcpu_vlapic(v)->hw.tdt_msr = 0; } -static int vlapic_reg_write(struct vcpu *v, - unsigned int offset, uint32_t val) +static void vlapic_reg_write(struct vcpu *v, + unsigned int offset, uint32_t val) { struct vlapic *vlapic = vcpu_vlapic(v); - int rc = X86EMUL_OKAY; memset(&vlapic->loaded, 0, sizeof(vlapic->loaded)); @@ -815,14 +814,7 @@ static int vlapic_reg_write(struct vcpu HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER, "timer divisor is %#x", vlapic->hw.timer_divisor); break; - - default: - break; } - if (rc == X86EMUL_UNHANDLEABLE) - gdprintk(XENLOG_DEBUG, - "Local APIC Write wrong to register %#x\n", offset); - return rc; } static int vlapic_write(struct vcpu *v, unsigned long address, @@ -871,7 +863,9 @@ static int vlapic_write(struct vcpu *v, else if ( unlikely(offset & 3) ) goto unaligned_exit_and_crash; - return vlapic_reg_write(v, offset, val); + vlapic_reg_write(v, offset, val); + + return X86EMUL_OKAY; unaligned_exit_and_crash: gprintk(XENLOG_ERR, "Unaligned LAPIC write: len=%u offset=%#x.\n", @@ -886,14 +880,18 @@ int vlapic_apicv_write(struct vcpu *v, u struct vlapic *vlapic = vcpu_vlapic(v); uint32_t val = vlapic_get_reg(vlapic, offset); - if ( !vlapic_x2apic_mode(vlapic) ) - return vlapic_reg_write(v, offset, val); + if ( vlapic_x2apic_mode(vlapic) ) + { + if ( offset != APIC_SELF_IPI ) + return X86EMUL_UNHANDLEABLE; - if ( offset != APIC_SELF_IPI ) - return X86EMUL_UNHANDLEABLE; + offset = APIC_ICR; + val = APIC_DEST_SELF | (val & APIC_VECTOR_MASK); + } + + vlapic_reg_write(v, offset, val); - return vlapic_reg_write(v, APIC_ICR, - APIC_DEST_SELF | (val & APIC_VECTOR_MASK)); + return X86EMUL_OKAY; } int hvm_x2apic_msr_write(struct vcpu *v, unsigned int msr, uint64_t msr_content) @@ -971,7 +969,9 @@ int hvm_x2apic_msr_write(struct vcpu *v, return X86EMUL_UNHANDLEABLE; } - return vlapic_reg_write(v, offset, msr_content); + vlapic_reg_write(v, offset, msr_content); + + return X86EMUL_OKAY; } static int vlapic_range(struct vcpu *v, unsigned long addr)