Received: by 10.223.164.202 with SMTP id h10csp1562368wrb; Wed, 15 Nov 2017 23:50:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMYVeHp7ceEvWtjQAMfus7ajGYF1FiMtPcVYa/ewQiUlfF1Yd3gl2xRyYOwc6MwRsDM7Bdcw X-Received: by 10.159.205.130 with SMTP id v2mr838152plo.105.1510818613246; Wed, 15 Nov 2017 23:50:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510818613; cv=none; d=google.com; s=arc-20160816; b=0moyd9PVckpMBF3x7KNi21VXaddrspJhczGuHoKR7iL67euvu+iXAEHwq7dNF9h7j4 kO2SdZmfHbNDZgtH88aaKBxhOp7lz3lhUmywRhCLdLIjUabLYdUu0VWTtJzjTXim+JGJ lr245VhsKi2uTEQ7JVY23bkV7df7LfIsJXp0yc3HPNcsUEC1HlRN6WBmxSs18RRWVovo BnxBncC/nIp7zbpON+ZYFjeg4FRy8H6we7AhKhm1kYfU5Qbbn+WYXFXiMLoa4oTNMc9B IFxadMUKjMXZkAM4x77Xh6NlU6IAqwqqEZjJtayPWdrf2NjGarp0oDmJ+apyWEC9hvpJ AMRQ== 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=KwN4D0KYq4pExYuxQHYTINyQkid2DgC1L3IrtSHeCwA=; b=DvB5rnE/YMxEH2GclpgOKOsPQ1PRyq1YA/NUNoczrC++q3kGmhXjSyf0W33Rsua7kp xn+upGuLuvVuTZn5s8vMewWdiJ3C+9fumk9PnQSDQVyaOnVl8hPAjFV1Mjc5ru8yAcEh alYs7+vI2+M3Dn90Dw3CSO0o6flj82Dej1nqNfbbseJHep/eypNXAJEW2xdzxw+0fPy1 u3wx30sBAkeayHiKETen8R/lr2af6Hg7HKTOXkOdf/Y54kasijH0tnowPpvXkik+2ITe qM/W4I9Zn4iAsC8iKKY7n84joNHFliJkwTVtTRe6XprPO6fsblSvK01PVFgCUL5QuHGz V0Hw== 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 j21si481501pfh.202.2017.11.15.23.50.00; Wed, 15 Nov 2017 23:50:13 -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 S1759404AbdKPHrz (ORCPT + 91 others); Thu, 16 Nov 2017 02:47:55 -0500 Received: from david.siemens.de ([192.35.17.14]:50133 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932611AbdKPHrp (ORCPT ); Thu, 16 Nov 2017 02:47:45 -0500 Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id vAG7Qs6o009635 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Nov 2017 08:26:55 +0100 Received: from md1f2u6c.ww002.siemens.net ([167.87.32.158]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id vAG7QrlS029336; Thu, 16 Nov 2017 08:26:54 +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 03/10] x86: jailhouse: Enable APIC and SMP support Date: Thu, 16 Nov 2017 08:26:45 +0100 Message-Id: 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 virtualization to switch 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 | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c index 34bfdfe29a04..56d22b4f9ffd 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 @@ -235,7 +236,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 bc0f49a6172d..ce9416c70656 100644 --- a/arch/x86/kernel/jailhouse.c +++ b/arch/x86/kernel/jailhouse.c @@ -11,6 +11,7 @@ */ #include +#include #include #include #include @@ -48,10 +49,16 @@ static uint32_t __init jailhouse_detect(void) return jailhouse_cpuid_base(); } +static unsigned int x2apic_get_apic_id(unsigned long id) +{ + return id; +} + static void __init jailhouse_init_platform(void) { u64 pa_data = boot_params.hdr.setup_data; struct jailhouse_setup_data *data; + unsigned int cpu; data = early_memremap(pa_data, sizeof(*data)); @@ -59,6 +66,23 @@ static void __init jailhouse_init_platform(void) data->compatible_version > SETUP_REQUIRED_VERSION) panic("Jailhouse: Unsupported setup data structure"); +#ifdef CONFIG_X86_X2APIC + /* + * Register x2APIC handlers early. We need them when running + * register_lapic_address. + */ + if (x2apic_enabled()) { + apic->read = native_apic_msr_read; + apic->write = native_apic_msr_write; + apic->get_apic_id = x2apic_get_apic_id; + } +#endif + register_lapic_address(0xfee00000); + for (cpu = 0; cpu < data->num_cpus; cpu++) + generic_processor_info(data->cpu_ids[cpu], + boot_cpu_apic_version); + smp_found_config = 1; + early_memunmap(data, sizeof(*data)); } @@ -67,10 +91,20 @@ 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, + .x2apic_available = jailhouse_x2apic_available, }, }; -- 2.12.3 From 1585388103799055478@xxx Wed Nov 29 08:25:16 +0000 2017 X-GM-THRID: 1585301606298575915 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread