From patchwork Tue May 24 09:16:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1634908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=UM0ajSUg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L6pVY3YNkz9sG4 for ; Tue, 24 May 2022 19:16:53 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4L6pVY0nR2z3bcW for ; Tue, 24 May 2022 19:16:53 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=UM0ajSUg; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1033; helo=mail-pj1-x1033.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=UM0ajSUg; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4L6pVS2TmFz3046 for ; Tue, 24 May 2022 19:16:47 +1000 (AEST) Received: by mail-pj1-x1033.google.com with SMTP id nk9-20020a17090b194900b001df2fcdc165so1588424pjb.0 for ; Tue, 24 May 2022 02:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=R6s6tHM10gZRwdhYyBhwQwXKf6LRuWwDMw/48W8SZRc=; b=UM0ajSUgtNmWHWk70goWGg8/syyq/54oWDrAEV9lMAnGq49sH5Mu15rdqJX1xw6Swf iWPO2iE5PV+FUzu7/WoscyOXFNniWfT7RDJpIPcXSp61xpD1e+w45xcwWhDApJBFl7U4 7IMsYrdjDSEIMu6JDIxYGU2u9OBc/0vJdzNFAWoSphTblLDlS1m6hqlFETZCwhWPFppg 1m1rrdO4zNmQGAqHQklpvtrrJM5FEBq91bWGxOmiGkxflW2N2bJTn+G9NyFY9KHk8c4F sdDdquoSzjVJSeHNFgj7C99J+ES2esQDhoxBuTxRUE2wU6yn9H1UX+t1/GW5xMC6MKJm wl1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=R6s6tHM10gZRwdhYyBhwQwXKf6LRuWwDMw/48W8SZRc=; b=y8qGMZhyO3LhCc2R00fOPtQrKhz8E+UfUuYEHup+I5sKbrgB+9esGD2l3YibaDsdeq 2Ee0vHX9IkrjsOIKaGsPfwKhlggstkQxxtbrRGJoDpKS5JpBOw0IGu8cxg2CwEcxPUlI YIJ7mRCkGt8g7fyxXU/xyyAYFotMIJAfdX+vJSZaOkzih6uJ+AoRgEAr7OyT+90l/eZ0 i/r4mg01pxuuU4BrCzXwkPx2CA+H+bPuDT/EMqidgNGF4MN48Y5bpmAxlSds4ZiGY5QR 6mKwpMYvzhY6xuo8MjozSX0EHeqd6wukMpcLT4upjij8kYkGPttLKHsEwV3vwFZoliOr Ozkw== X-Gm-Message-State: AOAM533LARTrDx/+ZNT699vEOxQ/hgQYtT/8qlMrj7lpOw6BRmW/H/v5 2CTi8VpQdrpwCbl6jVPD/IsSU2S3zD8I2Q== X-Google-Smtp-Source: ABdhPJwmU5LiqIHT/y9XwPY98tuKG4Wou/p0t5cTg3D474xk/7AtRIl9EILdKTdIFTFCvXa77mlJ2w== X-Received: by 2002:a17:90a:cf95:b0:1df:4ff6:628f with SMTP id i21-20020a17090acf9500b001df4ff6628fmr3569005pju.108.1653383805175; Tue, 24 May 2022 02:16:45 -0700 (PDT) Received: from bobo.ozlabs.ibm.com ([118.209.250.103]) by smtp.gmail.com with ESMTPSA id u5-20020a170903124500b0015e8d4eb23dsm6760553plh.135.2022.05.24.02.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 02:16:44 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Tue, 24 May 2022 19:16:37 +1000 Message-Id: <20220524091637.489123-1-npiggin@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [Skiboot] [PATCH v2] core: detect LPAR-per-core mode and report in dt X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Some firmware configurations boot in LPAR-per-core mode, which is not compatible with KVM on POWER9 and later machines. Detect which LPAR mode the boot core is in (all others will be set the same way), and if booted in LPAR-per-core mode then print a warning and add a device-tree entry that the OS can test for. Signed-off-by: Nicholas Piggin --- v2: - Fix make check compile core/init.c | 38 ++++++++++++++++++++++++++++++++++++++ hdata/cpu-common.c | 2 ++ hdata/test/hdata_to_dt.c | 2 ++ include/skiboot.h | 2 ++ 4 files changed, 44 insertions(+) diff --git a/core/init.c b/core/init.c index a1fd5f2b..005ecf31 100644 --- a/core/init.c +++ b/core/init.c @@ -48,6 +48,7 @@ #include #include #include +#include #include enum proc_gen proc_gen; @@ -1026,6 +1027,40 @@ static void mask_pc_system_xstop(void) } } +bool lpar_per_core = false; + +static void probe_lpar_per_core(void) +{ + struct cpu_thread *cpu = this_cpu(); + uint32_t chip_id = pir_to_chip_id(cpu->pir); + uint32_t core_id = pir_to_core_id(cpu->pir); + uint64_t addr; + uint64_t core_thread_state; + int rc; + + if (chip_quirk(QUIRK_MAMBO_CALLOUTS) || chip_quirk(QUIRK_AWAN)) + return; + + if (proc_gen == proc_gen_p9) + addr = XSCOM_ADDR_P9_EC(core_id, P9_CORE_THREAD_STATE); + else if (proc_gen == proc_gen_p10) + addr = XSCOM_ADDR_P10_EC(core_id, P10_EC_CORE_THREAD_STATE); + else + return; + + rc = xscom_read(chip_id, addr, &core_thread_state); + if (rc) { + prerror("Error reading CORE_THREAD_STATE rc:%d on PIR:%x\n", + rc, cpu->pir); + return; + } + + if (core_thread_state & PPC_BIT(62)) { + lpar_per_core = true; + prlog(PR_WARNING, "LPAR-per-core mode detected. KVM may not be usable."); + } +} + /* Called from head.S, thus no prototype. */ void __noreturn __nomcount main_cpu_entry(const void *fdt); @@ -1211,6 +1246,9 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* Once all CPU are up apply this workaround */ mask_pc_system_xstop(); + /* P9/10 may be in LPAR-per-core mode, which is incompatible with KVM */ + probe_lpar_per_core(); + /* Add the /opal node to the device-tree */ add_opal_node(); diff --git a/hdata/cpu-common.c b/hdata/cpu-common.c index 2248f9b6..4ba1430b 100644 --- a/hdata/cpu-common.c +++ b/hdata/cpu-common.c @@ -127,6 +127,8 @@ struct dt_node * add_core_common(struct dt_node *cpus, dt_add_property_cells(cpu, "ibm,mmu-pid-bits", 20); dt_add_property_cells(cpu, "ibm,mmu-lpid-bits", 12); } + if (lpar_per_core) + dt_add_property(cpu, "ibm,mmu-lpar-per-core", NULL, 0); /* HPT segment page size encodings, common to all supported CPUs */ dt_add_property_cells(cpu, "ibm,segment-page-sizes", diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c index 1729f1ca..ead6e3c9 100644 --- a/hdata/test/hdata_to_dt.c +++ b/hdata/test/hdata_to_dt.c @@ -104,6 +104,8 @@ static unsigned long fake_pvr = PVR_P8; unsigned int cpu_thread_count = 8; +bool lpar_per_core; + static inline unsigned long mfspr(unsigned int spr) { assert(spr == SPR_PVR); diff --git a/include/skiboot.h b/include/skiboot.h index db08f45f..b0b75a42 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -103,6 +103,8 @@ enum proc_gen { }; extern enum proc_gen proc_gen; +extern bool lpar_per_core; + extern unsigned int pcie_max_link_speed; /* Convert a 4-bit number to a hex char */