From patchwork Thu Mar 24 11:30:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8660101 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9DB99C0553 for ; Thu, 24 Mar 2016 11:32:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9FE0720395 for ; Thu, 24 Mar 2016 11:32:22 +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 8324920382 for ; Thu, 24 Mar 2016 11:32:21 +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 1aj3Sr-00063p-Pl; Thu, 24 Mar 2016 11:30:09 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj3Sp-00063N-OM for xen-devel@lists.xenproject.org; Thu, 24 Mar 2016 11:30:08 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id C2/98-04065-FBFC3F65; Thu, 24 Mar 2016 11:30:07 +0000 X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1458819004!33535727!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 36022 invoked from network); 24 Mar 2016 11:30:06 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-16.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 24 Mar 2016 11:30:06 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 24 Mar 2016 05:30:04 -0600 Message-Id: <56F3DDCC02000078000E0087@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Thu, 24 Mar 2016 05:30:04 -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 3/3] x86/HVM: terminate writes to PM_TMR port 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 There's no point in forwarding these to the device model. Signed-off-by: Jan Beulich x86/HVM: terminate writes to PM_TMR port There's no point in forwarding these to the device model. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/pmtimer.c +++ b/xen/arch/x86/hvm/pmtimer.c @@ -217,36 +217,30 @@ static int handle_pmt_io( struct vcpu *v = current; PMTState *s = &v->domain->arch.hvm_domain.pl_time->vpmt; - if ( bytes != 4 ) + if ( bytes != 4 || dir != IOREQ_READ ) { gdprintk(XENLOG_WARNING, "HVM_PMT bad access\n"); *val = ~0; - return X86EMUL_OKAY; } - - if ( dir == IOREQ_READ ) + else if ( spin_trylock(&s->lock) ) { - if ( spin_trylock(&s->lock) ) - { - /* We hold the lock: update timer value and return it. */ - pmt_update_time(s); - *val = s->pm.tmr_val; - spin_unlock(&s->lock); - } - else - { - /* - * Someone else is updating the timer: rather than do the work - * again ourselves, wait for them to finish and then steal their - * updated value with a lock-free atomic read. - */ - spin_barrier(&s->lock); - *val = *(volatile uint32_t *)&s->pm.tmr_val; - } - return X86EMUL_OKAY; + /* We hold the lock: update timer value and return it. */ + pmt_update_time(s); + *val = s->pm.tmr_val; + spin_unlock(&s->lock); + } + else + { + /* + * Someone else is updating the timer: rather than do the work + * again ourselves, wait for them to finish and then steal their + * updated value with a lock-free atomic read. + */ + spin_barrier(&s->lock); + *val = read_atomic(&s->pm.tmr_val); } - return X86EMUL_UNHANDLEABLE; + return X86EMUL_OKAY; } static int pmtimer_save(struct domain *d, hvm_domain_context_t *h) Reviewed-by: Andrew Cooper --- a/xen/arch/x86/hvm/pmtimer.c +++ b/xen/arch/x86/hvm/pmtimer.c @@ -217,36 +217,30 @@ static int handle_pmt_io( struct vcpu *v = current; PMTState *s = &v->domain->arch.hvm_domain.pl_time->vpmt; - if ( bytes != 4 ) + if ( bytes != 4 || dir != IOREQ_READ ) { gdprintk(XENLOG_WARNING, "HVM_PMT bad access\n"); *val = ~0; - return X86EMUL_OKAY; } - - if ( dir == IOREQ_READ ) + else if ( spin_trylock(&s->lock) ) { - if ( spin_trylock(&s->lock) ) - { - /* We hold the lock: update timer value and return it. */ - pmt_update_time(s); - *val = s->pm.tmr_val; - spin_unlock(&s->lock); - } - else - { - /* - * Someone else is updating the timer: rather than do the work - * again ourselves, wait for them to finish and then steal their - * updated value with a lock-free atomic read. - */ - spin_barrier(&s->lock); - *val = *(volatile uint32_t *)&s->pm.tmr_val; - } - return X86EMUL_OKAY; + /* We hold the lock: update timer value and return it. */ + pmt_update_time(s); + *val = s->pm.tmr_val; + spin_unlock(&s->lock); + } + else + { + /* + * Someone else is updating the timer: rather than do the work + * again ourselves, wait for them to finish and then steal their + * updated value with a lock-free atomic read. + */ + spin_barrier(&s->lock); + *val = read_atomic(&s->pm.tmr_val); } - return X86EMUL_UNHANDLEABLE; + return X86EMUL_OKAY; } static int pmtimer_save(struct domain *d, hvm_domain_context_t *h)