From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18405C67861 for ; Fri, 5 Apr 2024 08:51:54 +0000 (UTC) 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=20230601 header.b=dhYtTS9x; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4V9sfw5LbLz3w7M for ; Fri, 5 Apr 2024 19:51:52 +1100 (AEDT) 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=20230601 header.b=dhYtTS9x; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::32d; helo=mail-ot1-x32d.google.com; envelope-from=npiggin@gmail.com; receiver=lists.ozlabs.org) Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) (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 4V9sL63qX5z3vcW for ; Fri, 5 Apr 2024 19:37:18 +1100 (AEDT) Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6e675181ceaso1085351a34.2 for ; Fri, 05 Apr 2024 01:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712306235; x=1712911035; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NtLrnSXqdt678CiS0tNUCc+5b/rRAvRjP5Z8cb4bKlQ=; b=dhYtTS9xHUT8EWUP9617fD8SINkP8760K4ZFkF3GqHkoZgAyIPCqiu4aMg9vh+pK0x XOBpcwW1hKwEyjQ1z8ViAXwSPl5FZgDUdiWBIxe9+4MrZOYfyx8w9Y3WQf8P7n+UnXwD +gGbUW2A2vOGTFqEDGItgbrUKNLQLvcdilxTuZLuPkJtPIKZx226s7A7TbAqxdW38O/H CpvD01xVU7qIoGZ5Mj65FG4HlsSntVoIc8YAr9yRi45af/KnlAVgqHx+UtkNPp/bJzl6 SeMrxvSRU4yl+EroiEvQIqmqrB8EDMzF9JJAmL3bSlEr22Y22D7cidiJ53OtElv2V7Gm rOww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712306235; x=1712911035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NtLrnSXqdt678CiS0tNUCc+5b/rRAvRjP5Z8cb4bKlQ=; b=P5etVVtnmShnscQPIZy3BDtbZ1okDjt4tI0LfN+/zLvnokbSN2dlSafh2EpHJ6JhiS 4SdFJTo1qjh4mh+60Fs+8RUCGiyOwPA5+gfEmAkzpMF894ZTYhLCuyQ8bQH7PfhipEcR jBm272EXhT0DYE1UYjvvwEzMkHlV5cZ1ppe6AOA3YNJwKyFQ8nXMUuWtZWxyjt4gohf0 rnEg8NEjGO7AJfym2CSS5fqFrj39vaVokKewdXuZhME76fmlVLogXK90RpSHErUH2Gpl dtJrZqhYJRMl3YwV51mg59DGEe+F1huNLOvL4WBHSbTQuzVszLnGdKDIh2oo/uDziB5N 3KpA== X-Forwarded-Encrypted: i=1; AJvYcCXRCkEDvSXRX/7ewhrNOkEzSu1YExiiFPNd+9d7eV6g4okkuCsVYM9Ke0mBK4yuD27zXqlZNjRcDYHf0bXqbK0d09C5X/IGStAXyjXK+w== X-Gm-Message-State: AOJu0YzYKRH3mARs1lUfMEXZZdTYiMaMrShnyth1ZkQ2F0es0kDp4UT8 WqmLsbkH82CtfWLh6KlxHbM6VlP2FCCw7x7AQsWzwHO3HeaO48Ze X-Google-Smtp-Source: AGHT+IHmWOpjV+Y1L3Hng8oVd+HC+SSPr9KDiyUK4PN0GZhAizbWKsuQLfdEdo5jlJnCbyqJBRWlZg== X-Received: by 2002:a05:6830:6c18:b0:6e8:9b1a:6bc2 with SMTP id ds24-20020a0568306c1800b006e89b1a6bc2mr930386otb.20.1712306235503; Fri, 05 Apr 2024 01:37:15 -0700 (PDT) Received: from wheely.local0.net (124-169-104-130.tpgi.com.au. [124.169.104.130]) by smtp.gmail.com with ESMTPSA id y7-20020a63de47000000b005e838b99c96sm808638pgi.80.2024.04.05.01.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:37:15 -0700 (PDT) From: Nicholas Piggin To: Thomas Huth Subject: [kvm-unit-tests PATCH v8 21/35] powerpc: Remove broken SMP exception stack setup Date: Fri, 5 Apr 2024 18:35:22 +1000 Message-ID: <20240405083539.374995-22-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240405083539.374995-1-npiggin@gmail.com> References: <20240405083539.374995-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , kvm@vger.kernel.org, Nicholas Piggin , Andrew Jones , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" The exception stack setup does not work correctly for SMP, because it is the boot processor that calls cpu_set() which sets SPRG2 to the exception stack, not the target CPU itself. So secondaries never got their SPRG2 set to a valid exception stack. Remove the SMP code and just set an exception stack for the boot processor. Make the stack 64kB while we're here, to match the size of the regular stack. Signed-off-by: Nicholas Piggin --- lib/powerpc/setup.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c index 9b665f59c..496af40f8 100644 --- a/lib/powerpc/setup.c +++ b/lib/powerpc/setup.c @@ -42,10 +42,6 @@ struct cpu_set_params { uint64_t tb_hz; }; -#define EXCEPTION_STACK_SIZE (32*1024) /* 32kB */ - -static char exception_stack[NR_CPUS][EXCEPTION_STACK_SIZE]; - static void cpu_set(int fdtnode, u64 regval, void *info) { static bool read_common_info = false; @@ -56,10 +52,6 @@ static void cpu_set(int fdtnode, u64 regval, void *info) cpus[cpu] = regval; - /* set exception stack address for this CPU (in SPGR0) */ - asm volatile ("mtsprg0 %[addr]" :: - [addr] "r" (exception_stack[cpu + 1])); - if (!read_common_info) { const struct fdt_property *prop; u32 *data; @@ -180,6 +172,10 @@ static void mem_init(phys_addr_t freemem_start) ? __icache_bytes : __dcache_bytes); } +#define EXCEPTION_STACK_SIZE SZ_64K + +static char boot_exception_stack[EXCEPTION_STACK_SIZE]; + void setup(const void *fdt) { void *freemem = &stacktop; @@ -189,6 +185,10 @@ void setup(const void *fdt) cpu_has_hv = !!(mfmsr() & (1ULL << MSR_HV_BIT)); + /* set exception stack address for this CPU (in SPGR0) */ + asm volatile ("mtsprg0 %[addr]" :: + [addr] "r" (boot_exception_stack)); + enable_mcheck(); /* -- 2.43.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 621B4145B09 for ; Fri, 5 Apr 2024 08:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712306237; cv=none; b=ox9nR815rPVFZjHMH31MbWciSld5GNKB7pPUu/j6wCG94VGnsjSlXG6oCSCuj6UfKlZ8uPS91xmDCNBnsFb8JtcYS1LDAeLcqoAm0wwC928izc4Nmpe9M/gHBt/HA/A6NCLjsZTFf61Im0gK13q3x7jyO/ZbQ+diOx7wrsKAThU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712306237; c=relaxed/simple; bh=V1c2UIEnPXrwqACWciLzGfJgkj2oxvNvvQtouc/639c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fsGZ6tZBAxMrek01t4U/BqG6cF2samN+9npEwc2g0qAq2vDhv99khuHMdLF8GLHpPHdlECig6JGl+jSyNh9bjU5VcYBwwLio0NXIiGF6r7L2/xe7WeyjD9BVYWXECXh6Cq3OYSc2BoFz9RD8t91e0eCu2eo8w2JrYHCzpgoSBhE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SR6D8fiD; arc=none smtp.client-ip=209.85.210.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SR6D8fiD" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6e0f43074edso1169432a34.1 for ; Fri, 05 Apr 2024 01:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712306235; x=1712911035; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NtLrnSXqdt678CiS0tNUCc+5b/rRAvRjP5Z8cb4bKlQ=; b=SR6D8fiDOMly5BVrjyK7d7+2yL471GAwk1VVHmmKkDw4J7J9igDAhdSe4rBx7peN6A pjtjiyTThtXHaPuPrvhetgId7Eky44XoT43RDipzIux3z5S2aWpy3rU5+chWhJ4Q2l9P ojkHuFdpEbccU8E2xyjUg+IS1wd5sEvVdlUqI0fuPr2TR0hS39DML5dusZwFwT7TnEbX agvco404NCZAC007RVbfJCFUgQDUP05UlaP/WIRAr+rPFWvO3y2PCj3Kmb1P4FTmSWZH wVSAZQWglDZrI+L+G35AT8A5qQsRwozFX1YHneUxubAk9FXEs22wvvHTO+KLaRyKjzDC gZbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712306235; x=1712911035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NtLrnSXqdt678CiS0tNUCc+5b/rRAvRjP5Z8cb4bKlQ=; b=j878LWjEpXdyyLY//oReVwDkscSGm6stW3E1LVhv4CeAN5z2gi6pGmSMc6eCmE3WEN /VNOyAEPVRriVXLQP8LmEp7QYuCFqADMFM0ujo6r07eJWSx4AHVRJbdhMi/8jnmHjdhA 4glskFLDtBPN+xfF3ktJnlTCved5ALVBfe5E2syqPfPcXsWeYrXmZTXCWcvTVeUcTt7O OHBTEiabBKJe8BNOCWhChA7ld+zDkyk6c8PWY9mYrh2XdDWZtw+StBXwIhsRk4URa8bv 5CEiyhR4l9L53ICoyy21I/d5GFHWZ59LZ8PzaqFeuwtX9g/rCAgpxPOK/HxbuedQfQaF jn3A== X-Forwarded-Encrypted: i=1; AJvYcCU4pPg6EqesoB/rs6TPrNyGzC3e3xh0dP3FBv4DVnQTwxWP2iJ+Tw18LKwLQBbKerdLtVXlnvWaZ9yVLt0MiYvL32To X-Gm-Message-State: AOJu0YwiQ3xMTcAmSZfw/0vse1o2erzTdjgk5+7t4h4cMzrX202hUpmh u04ePKGeS2oQJS54yH5FQoWS7A9gVgOXnWZD/DoPg6/IjcIhi5iPCcvQ2mtl X-Google-Smtp-Source: AGHT+IHmWOpjV+Y1L3Hng8oVd+HC+SSPr9KDiyUK4PN0GZhAizbWKsuQLfdEdo5jlJnCbyqJBRWlZg== X-Received: by 2002:a05:6830:6c18:b0:6e8:9b1a:6bc2 with SMTP id ds24-20020a0568306c1800b006e89b1a6bc2mr930386otb.20.1712306235503; Fri, 05 Apr 2024 01:37:15 -0700 (PDT) Received: from wheely.local0.net (124-169-104-130.tpgi.com.au. [124.169.104.130]) by smtp.gmail.com with ESMTPSA id y7-20020a63de47000000b005e838b99c96sm808638pgi.80.2024.04.05.01.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 01:37:15 -0700 (PDT) From: Nicholas Piggin To: Thomas Huth Cc: Nicholas Piggin , Laurent Vivier , Andrew Jones , Paolo Bonzini , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org Subject: [kvm-unit-tests PATCH v8 21/35] powerpc: Remove broken SMP exception stack setup Date: Fri, 5 Apr 2024 18:35:22 +1000 Message-ID: <20240405083539.374995-22-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240405083539.374995-1-npiggin@gmail.com> References: <20240405083539.374995-1-npiggin@gmail.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The exception stack setup does not work correctly for SMP, because it is the boot processor that calls cpu_set() which sets SPRG2 to the exception stack, not the target CPU itself. So secondaries never got their SPRG2 set to a valid exception stack. Remove the SMP code and just set an exception stack for the boot processor. Make the stack 64kB while we're here, to match the size of the regular stack. Signed-off-by: Nicholas Piggin --- lib/powerpc/setup.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/powerpc/setup.c b/lib/powerpc/setup.c index 9b665f59c..496af40f8 100644 --- a/lib/powerpc/setup.c +++ b/lib/powerpc/setup.c @@ -42,10 +42,6 @@ struct cpu_set_params { uint64_t tb_hz; }; -#define EXCEPTION_STACK_SIZE (32*1024) /* 32kB */ - -static char exception_stack[NR_CPUS][EXCEPTION_STACK_SIZE]; - static void cpu_set(int fdtnode, u64 regval, void *info) { static bool read_common_info = false; @@ -56,10 +52,6 @@ static void cpu_set(int fdtnode, u64 regval, void *info) cpus[cpu] = regval; - /* set exception stack address for this CPU (in SPGR0) */ - asm volatile ("mtsprg0 %[addr]" :: - [addr] "r" (exception_stack[cpu + 1])); - if (!read_common_info) { const struct fdt_property *prop; u32 *data; @@ -180,6 +172,10 @@ static void mem_init(phys_addr_t freemem_start) ? __icache_bytes : __dcache_bytes); } +#define EXCEPTION_STACK_SIZE SZ_64K + +static char boot_exception_stack[EXCEPTION_STACK_SIZE]; + void setup(const void *fdt) { void *freemem = &stacktop; @@ -189,6 +185,10 @@ void setup(const void *fdt) cpu_has_hv = !!(mfmsr() & (1ULL << MSR_HV_BIT)); + /* set exception stack address for this CPU (in SPGR0) */ + asm volatile ("mtsprg0 %[addr]" :: + [addr] "r" (boot_exception_stack)); + enable_mcheck(); /* -- 2.43.0