Received: by 10.223.164.202 with SMTP id h10csp1296880wrb; Mon, 27 Nov 2017 00:15:44 -0800 (PST) X-Google-Smtp-Source: AGs4zMZXJbt3A7O/ZCMW9NXByWhIqVuTTFh5e5LhSTFt3ac7qcweGm1kDntLg39xzWe27ukUjIoP X-Received: by 10.84.240.7 with SMTP id y7mr4708963plk.269.1511770544453; Mon, 27 Nov 2017 00:15:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511770544; cv=none; d=google.com; s=arc-20160816; b=wwZgIGDcUnGybfCHvpTn+zWQUC5JoMHZjQiBJuceTjbVNknpIrvcg8rdVUkJN3BRhd pMczYqI4eiNfKqUP2Ot3NG6Vm9LCmSi2k+87mXtfH6A/sZ7zAi/8UdC24Je2O/rjjZl9 nBI06WIg/GIKjYeXeQCCM6Po47V9xQ5hf5GN+xY2RYTm/kX5sS2GeLT36mxRW54NOLyU vTDlrHlnowJ1iey/pQW3hDw4slCt6F+5BA+/kusN4wg1VNa+KxQHtnWqmrXsBxFY7PGc Jnl4C5uR7JxisLrxnRe1/LeuK/wRKOFBeqk1qFwUf0isotyWj+hIjnd/jvBb0ydEh89Y Bg+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=fJv0oXqvfMYFIEs4tdb4RDV6MVlP/2Enj9960ygrJdo=; b=kXbV6noMNbGK5/7cvg7yl5+X7hnpfA44d+CZZTHFVFUXQ+ZYQMucudRSI0AAAOsSrn uBdWgAFB1SkJiijH7f6E1lPp96gCrcO2h3cN5M0XSsHHj36uRt+cKU+i24Mv0ZVhDABo PBNNB+bpFUcCnv6HLBR33H0xwtw+iO66pO2jUVx01xTTgZr6dAVr88/75b9ejeI0K4LB +c4rvGKfFafrZZ97pxY0Fos2hdbpK7Ln6zlgroR1lwF5YtJ+IMnX1WxsSVeK14UBLefm rrWXKd/m70KKH0E5cUhF9HF1w7AeR7+2Ga4aX8rWJEf+KRk7cZZ3j50R9f02zYHpg0Fv uxuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y92si4577620plb.584.2017.11.27.00.15.33; Mon, 27 Nov 2017 00:15:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751859AbdK0INd (ORCPT + 78 others); Mon, 27 Nov 2017 03:13:33 -0500 Received: from goliath.siemens.de ([192.35.17.28]:58551 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751397AbdK0IMI (ORCPT ); Mon, 27 Nov 2017 03:12:08 -0500 Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id vAR8BxMT013936 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Nov 2017 09:11:59 +0100 Received: from md1f2u6c.ww002.siemens.net ([167.87.32.153]) by mail3.siemens.de (8.15.2/8.15.2) with ESMTP id vAR8BtEX021016; Mon, 27 Nov 2017 09:11:58 +0100 From: Jan Kiszka To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, Linux Kernel Mailing List , jailhouse-dev@googlegroups.com Subject: [PATCH v2 05/12] x86/jailhouse: Enable APIC and SMP support Date: Mon, 27 Nov 2017 09:11:47 +0100 Message-Id: <8b2255da0a9856c530293a67aa9d6addfe102a2b.1511770314.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kiszka Register the APIC which Jailhouse always exposes at 0xfee00000 if in xAPIC mode or via MSRs as x2APIC. The latter is only available if it was already activated because there is no support for switching its mode during runtime. Jailhouse requires the APIC to be operated in phys-flat mode. Ensure that this mode is selected by Linux. The available CPUs are taken from the setup data structure that the loader filled and registered with the kernel. Signed-off-by: Jan Kiszka --- arch/x86/kernel/apic/apic_flat_64.c | 4 +++- arch/x86/kernel/jailhouse.c | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c index 226a6ab22b35..408bf5abad4c 100644 --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -239,7 +240,8 @@ static void physflat_send_IPI_all(int vector) static int physflat_probe(void) { - if (apic == &apic_physflat || num_possible_cpus() > 8) + if (apic == &apic_physflat || num_possible_cpus() > 8 || + jailhouse_paravirt()) return 1; return 0; diff --git a/arch/x86/kernel/jailhouse.c b/arch/x86/kernel/jailhouse.c index fd71b278c308..9682e7089402 100644 --- a/arch/x86/kernel/jailhouse.c +++ b/arch/x86/kernel/jailhouse.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -31,12 +32,43 @@ static uint32_t __init jailhouse_detect(void) return jailhouse_cpuid_base(); } +static void __init jailhouse_get_smp_config(unsigned int early) +{ + unsigned int cpu; + + if (x2apic_enabled()) { + /* + * We do not have access to IR inside Jailhouse non-root cells. + * So we have to run in physical mode. + */ + x2apic_phys = 1; + + /* + * This will trigger the switch to apic_x2apic_phys. + * Empty OEM IDs ensure that only this APIC driver picks up + * the call. + */ + default_acpi_madt_oem_check("", ""); + } + + register_lapic_address(0xfee00000); + + for (cpu = 0; cpu < setup_data.num_cpus; cpu++) { + generic_processor_info(setup_data.cpu_ids[cpu], + boot_cpu_apic_version); + } + + smp_found_config = 1; +} + static void __init jailhouse_init_platform(void) { u64 pa_data = boot_params.hdr.setup_data; struct setup_data header; void *mapping; + x86_init.mpparse.get_smp_config = jailhouse_get_smp_config; + while (pa_data) { mapping = early_memremap(pa_data, sizeof(header)); memcpy(&header, mapping, sizeof(header)); @@ -68,8 +100,18 @@ bool jailhouse_paravirt(void) return jailhouse_cpuid_base() != 0; } +static bool jailhouse_x2apic_available(void) +{ + /* + * The x2APIC is only available if the root cell enabled it. Jailhouse + * does not support switching between xAPIC and x2APIC. + */ + return x2apic_enabled(); +} + const struct hypervisor_x86 x86_hyper_jailhouse __refconst = { .name = "Jailhouse", .detect = jailhouse_detect, .init.init_platform = jailhouse_init_platform, + .init.x2apic_available = jailhouse_x2apic_available, }; -- 2.12.3 From 1585216161732746525@xxx Mon Nov 27 10:52:19 +0000 2017 X-GM-THRID: 1585216161732746525 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread