From patchwork Tue Mar 19 20:02:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jennifer Herbert X-Patchwork-Id: 10860309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F3DB17E0 for ; Tue, 19 Mar 2019 20:06:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24AA0297F3 for ; Tue, 19 Mar 2019 20:06:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18FBA29800; Tue, 19 Mar 2019 20:06:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D7DEE297F3 for ; Tue, 19 Mar 2019 20:05:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6KxR-00039F-H2; Tue, 19 Mar 2019 20:03:33 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h6KxR-00039A-0V for xen-devel@lists.xenproject.org; Tue, 19 Mar 2019 20:03:33 +0000 X-Inumbo-ID: 10f42fdc-4a82-11e9-b03b-6bc82f2c7c24 Received: from SMTP03.CITRIX.COM (unknown [162.221.156.55]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 10f42fdc-4a82-11e9-b03b-6bc82f2c7c24; Tue, 19 Mar 2019 20:03:30 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.60,245,1549929600"; d="scan'208";a="81060873" From: Jennifer Herbert To: , , Date: Tue, 19 Mar 2019 20:02:19 +0000 Message-ID: <1553025739-92245-1-git-send-email-jennifer.herbert@citrix.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] xen/pv: Add PV specific legacy_pic struct to expose legacy IRQs. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Jennifer Herbert , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Boris Ostrovsky , Thomas Gleixner Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The ACPI tables doesn't always contain all IRQs for legacy devices such as RTC. Since no PIC controller is visible for a PV linux guest, under Xen, legacy_pic currently defaults to the null_legacy_pic - with reports no legacy IRQs. Since the commit "rtc: cmos: Do not assume irq 8 for rtc when there are no legacy irqs" by Hans de Goede (commit id: a1e23a42f1bdc00e32fc4869caef12e4e6272f26), the rtc now incorrectly decides it has no irq it can use, for some hardware. This patch rectifies the problem by providing a xen legacy_pic struct, which is much like the null_legacy_pic except that it reports NR_IRQS_LEGACY irqs. Signed-off-by: Jennifer Herbert --- arch/x86/xen/enlighten_pv.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c index c54a493..7644bdf 100644 --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,7 @@ #include #include +#include #include #include #include @@ -1188,6 +1190,41 @@ static void __init xen_dom0_set_legacy_features(void) x86_platform.legacy.rtc = 1; } +/* + * The ACPI tables doesn't always contain all IRQ's for legacy devices + * such as RTC. Since no PIC controller is visible, we'd otherwise + * default to the null_legacy_pic - with no legacy IRQs. To allow drivers + * to use these IRQs despite this, provide a xen specific legacy_pic + * structure, which is noop, other then reporting NR_IRQS_LEGACY irqs. + */ + +static void xen_legacy_pic_noop(void) { }; +static void xen_legacy_pic_uint_noop(unsigned int unused) { }; +static void xen_legacy_pic_int_noop(int unused) { }; +static int xen_legacy_pic_irq_pending_noop(unsigned int irq) +{ + return 0; +} + +static int xen_legacy_pic_probe(void) +{ + pr_info("Using Xen legacy PIC\n"); + return nr_legacy_irqs(); +} + +struct legacy_pic xen_legacy_pic = { + .nr_legacy_irqs = NR_IRQS_LEGACY, + .chip = &dummy_irq_chip, + .mask = xen_legacy_pic_uint_noop, + .unmask = xen_legacy_pic_uint_noop, + .mask_all = xen_legacy_pic_noop, + .restore_mask = xen_legacy_pic_noop, + .init = xen_legacy_pic_int_noop, + .probe = xen_legacy_pic_probe, + .irq_pending = xen_legacy_pic_irq_pending_noop, + .make_irq = xen_legacy_pic_uint_noop, +}; + /* First C function to be called on Xen boot */ asmlinkage __visible void __init xen_start_kernel(void) { @@ -1267,6 +1304,8 @@ asmlinkage __visible void __init xen_start_kernel(void) xen_init_capabilities(); + legacy_pic = &xen_legacy_pic; + #ifdef CONFIG_X86_LOCAL_APIC /* * set up the basic apic ops.