From patchwork Wed Jan 13 12:32:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 8024621 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 CD1CC9F96D for ; Wed, 13 Jan 2016 12:36:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D80EB20454 for ; Wed, 13 Jan 2016 12:36:21 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E03012045A for ; Wed, 13 Jan 2016 12:36:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJKbz-00054s-T8; Wed, 13 Jan 2016 12:33:15 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJKbx-00054C-KB for xen-devel@lists.xenproject.org; Wed, 13 Jan 2016 12:33:13 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id BA/FD-21901-80446965; Wed, 13 Jan 2016 12:33:12 +0000 X-Env-Sender: prvs=81391bf32=roger.pau@citrix.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1452688390!15293065!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14592 invoked from network); 13 Jan 2016 12:33:12 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 13 Jan 2016 12:33:12 -0000 X-IronPort-AV: E=Sophos;i="5.22,288,1449532800"; d="scan'208";a="324707623" From: Roger Pau Monne To: Date: Wed, 13 Jan 2016 13:32:17 +0100 Message-ID: <1452688338-70075-5-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 1.9.5 (Apple Git-50.3) In-Reply-To: <1452688338-70075-1-git-send-email-roger.pau@citrix.com> References: <1452688338-70075-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH 4/5] x86/PV: remove the emulated PIT X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org 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 The HVMlite series removed the initialization of the emulated PIT for PV guests, but the handler was still reachable, which means a PV guests can crash Xen if it pokes at IO ports 0x42, 0x43 or 0x61. Completely remove the PV PIT handler and move the PIT initialization to HVM guests only. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/domain.c | 3 --- xen/arch/x86/hvm/hvm.c | 2 ++ xen/arch/x86/hvm/i8254.c | 27 --------------------------- xen/arch/x86/traps.c | 12 ++---------- xen/include/asm-x86/hvm/vpt.h | 1 - 5 files changed, 4 insertions(+), 41 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 159d960..868ef49 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -647,9 +647,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, tsc_set_info(d, TSC_MODE_DEFAULT, 0UL, 0, 0); spin_lock_init(&d->arch.vtsc_lock); - /* PV/PVH guests get an emulated PIT too for video BIOSes to use. */ - pit_init(d, cpu_khz); - return 0; fail: diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 05c3ca1..28c6cd9 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1622,6 +1622,8 @@ int hvm_domain_initialise(struct domain *d) msixtbl_init(d); + pit_init(d, cpu_khz); + register_portio_handler(d, 0xe9, 1, hvm_print_line); register_portio_handler(d, 0xcf8, 4, hvm_access_cf8); diff --git a/xen/arch/x86/hvm/i8254.c b/xen/arch/x86/hvm/i8254.c index b517cd6..83eae33 100644 --- a/xen/arch/x86/hvm/i8254.c +++ b/xen/arch/x86/hvm/i8254.c @@ -558,33 +558,6 @@ static int handle_speaker_io( return X86EMUL_OKAY; } -int pv_pit_handler(int port, int data, int write) -{ - ioreq_t ioreq = { - .size = 1, - .type = IOREQ_TYPE_PIO, - .addr = port, - .dir = write ? IOREQ_WRITE : IOREQ_READ, - .data = data - }; - - if ( is_hardware_domain(current->domain) && hwdom_pit_access(&ioreq) ) - { - /* nothing to do */; - } - else - { - uint32_t val = data; - if ( port == 0x61 ) - handle_speaker_io(ioreq.dir, port, 1, &val); - else - handle_pit_io(ioreq.dir, port, 1, &val); - ioreq.data = val; - } - - return !write ? ioreq.data : 0; -} - /* * Local variables: * mode: C diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index e105b95..a9d7e83 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1839,11 +1839,7 @@ uint32_t guest_io_read(unsigned int port, unsigned int bytes, unsigned int size = 1; uint32_t sub_data = ~0; - if ( (port == 0x42) || (port == 0x43) || (port == 0x61) ) - { - sub_data = pv_pit_handler(port, 0, 0); - } - else if ( (port == RTC_PORT(0)) ) + if ( (port == RTC_PORT(0)) ) { sub_data = currd->arch.cmos_idx; } @@ -1908,11 +1904,7 @@ void guest_io_write(unsigned int port, unsigned int bytes, uint32_t data, { unsigned int size = 1; - if ( (port == 0x42) || (port == 0x43) || (port == 0x61) ) - { - pv_pit_handler(port, (uint8_t)data, 1); - } - else if ( (port == RTC_PORT(0)) ) + if ( (port == RTC_PORT(0)) ) { currd->arch.cmos_idx = data; } diff --git a/xen/include/asm-x86/hvm/vpt.h b/xen/include/asm-x86/hvm/vpt.h index 495d669..557bb4a 100644 --- a/xen/include/asm-x86/hvm/vpt.h +++ b/xen/include/asm-x86/hvm/vpt.h @@ -172,7 +172,6 @@ void create_periodic_time( uint64_t period, uint8_t irq, time_cb *cb, void *data); void destroy_periodic_time(struct periodic_time *pt); -int pv_pit_handler(int port, int data, int write); void pit_reset(struct domain *d); void pit_init(struct domain *d, unsigned long cpu_khz);