From patchwork Tue Apr 26 08:22:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8936051 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 2625DBF29F for ; Tue, 26 Apr 2016 08:25:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BA4320138 for ; Tue, 26 Apr 2016 08:25:00 +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 76A312012B for ; Tue, 26 Apr 2016 08:24:59 +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 1auyGi-00076N-IG; Tue, 26 Apr 2016 08:22:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1auyGh-00076F-KI for xen-devel@lists.xenproject.org; Tue, 26 Apr 2016 08:22:51 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 90/FA-04050-A552F175; Tue, 26 Apr 2016 08:22:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXS6fjDSzdKVT7 cYM0nAYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWNVwzO2gh+iFedmLGdvYPwp2MXIySEkkCfx ZutCVhCbV8BOYsf9p0wgtoSAocS++avYQGwWAVWJJc/egtlsAuoSbc+2A9VzcIgIGEicO5oEE mYW8JNYdaCFEcQWFvCSeNlxiQWkhFdAUOLvDmGIEjuJxRu/ME5g5JqFkJmFJANha0k8/HWLBc LWlli28DUzSDmzgLTE8n8cMOUT391nRVUCYntKfJ1wknUBI8cqRo3i1KKy1CJdQzO9pKLM9Iy S3MTMHF1DA2O93NTi4sT01JzEpGK95PzcTYzA4GMAgh2Mq7Z7HmKU5GBSEuX9M1kuXIgvKT+l MiOxOCO+qDQntfgQowwHh5IEb4WKfLiQYFFqempFWmYOMA5g0hIcPEoivCogad7igsTc4sx0i NQpRkUpcd4OkIQASCKjNA+uDRZ7lxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMWwAyhSczrw Ru+iugxUxAiy8fkgVZXJKIkJJqYOz5cOnx6uMlkZMmOtmvmjfVc5p5odvpg8oRN/WudraL8nM pPDzE0fjk5HV9Z/O/N9w/he/+uOHq2jOrlNxfnY0xO9zJ/0Tn/4WaLXedLyw6W3zHIjDrlf6+ JaIvPTy4Jxx5nFGu0D8h76ZkhHaefP59Vavyv5G6gaf3fVm048/ZgBPGXntKWjYrsRRnJBpqM RcVJwIAdXGt3LgCAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1461658968!10658214!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.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47720 invoked from network); 26 Apr 2016 08:22:49 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-6.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 26 Apr 2016 08:22:49 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Tue, 26 Apr 2016 02:22:47 -0600 Message-Id: <571F417A02000078000E5A98@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Tue, 26 Apr 2016 02:22:50 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Paul Durrant , Wei Liu Subject: [Xen-devel] [PATCH] x86/HVM: correct last address emulation acceptance check 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 For REPeated memory access instructions the repeat count also needs to be considered. Utilize that "last" already takes this into account. Also defer computing "last" until we really know we need it. Signed-off-by: Jan Beulich x86/HVM: correct last address emulation acceptance check For REPeated memory access instructions the repeat count also needs to be considered. Utilize that "last" already takes this into account. Also defer computing "last" until we really know we need it. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/intercept.c +++ b/xen/arch/x86/hvm/intercept.c @@ -34,16 +34,16 @@ static bool_t hvm_mmio_accept(const struct hvm_io_handler *handler, const ioreq_t *p) { - paddr_t first = hvm_mmio_first_byte(p); - paddr_t last = hvm_mmio_last_byte(p); + paddr_t first = hvm_mmio_first_byte(p), last; BUG_ON(handler->type != IOREQ_TYPE_COPY); if ( !handler->mmio.ops->check(current, first) ) return 0; - /* Make sure the handler will accept the whole access */ - if ( p->size > 1 && + /* Make sure the handler will accept the whole access. */ + last = hvm_mmio_last_byte(p); + if ( last != first && !handler->mmio.ops->check(current, last) ) domain_crash(current->domain); Reviewed-by: Paul Durrant --- a/xen/arch/x86/hvm/intercept.c +++ b/xen/arch/x86/hvm/intercept.c @@ -34,16 +34,16 @@ static bool_t hvm_mmio_accept(const struct hvm_io_handler *handler, const ioreq_t *p) { - paddr_t first = hvm_mmio_first_byte(p); - paddr_t last = hvm_mmio_last_byte(p); + paddr_t first = hvm_mmio_first_byte(p), last; BUG_ON(handler->type != IOREQ_TYPE_COPY); if ( !handler->mmio.ops->check(current, first) ) return 0; - /* Make sure the handler will accept the whole access */ - if ( p->size > 1 && + /* Make sure the handler will accept the whole access. */ + last = hvm_mmio_last_byte(p); + if ( last != first && !handler->mmio.ops->check(current, last) ) domain_crash(current->domain);