From patchwork Fri Nov 27 04:27:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1406974 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cj1p04Rwhz9sRR for ; Fri, 27 Nov 2020 15:28:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: 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=20161025 header.b=lp233PA5; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4Cj1p00LhWzDrTs for ; Fri, 27 Nov 2020 15:28:08 +1100 (AEDT) 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::644; helo=mail-pl1-x644.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com 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=20161025 header.b=lp233PA5; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (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 4Cj1nq5tHwzDrTK for ; Fri, 27 Nov 2020 15:27:59 +1100 (AEDT) Received: by mail-pl1-x644.google.com with SMTP id x4so354267pln.8 for ; Thu, 26 Nov 2020 20:27:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ahFWjC42Z88y+79KgVO+srmdJx7wWa0LbTmJ3adRWgQ=; b=lp233PA5mk1dZ7ChBPYbqbqe4HzgxsqvbToBBA7wFjunt/ztkCpKUKv+Ofb8dO0DJj khKGBPBJjEtORg7YavLGkk1YJYyM6faJGoDYKds5K/Jhd9c+pwqHG0nv5lV+yMElu0Dl 0JhxzZ0Ne3c0oafXvbTFuZg8NILrCyzjV1yzriURg4Gm4YJ8OPbo/yEJe15KrpzQ+ao/ ObNMxYkp8WqaHrQDwY8nLhTJOBb8XoZ8V4KjW2oXUy/R1DNtZvikb7UbFwk87BouNh8T QbFfoqgSZePRlJm+EEbu6cn3IkEfNlxEJMQyuYtN5qevaQH9Kpcqy2rB4D95pRF0NV8Y KnTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ahFWjC42Z88y+79KgVO+srmdJx7wWa0LbTmJ3adRWgQ=; b=NtshGKk6r+BFemQW45SyHHPvtF9/xSxf6BB1AXuH3IFTf4cdDJWoBkcO8JfIqDqtza l7B800m40RiA2w4eIDp6kJdK/7lFxio+YehNIwQJz9PXQa9voe6RYNbSHeHemBBk3u/z Z12w5N0F48oaDGX1uxkyy8gRB3grOJEWxYwpnS+vCfTOvx/F3n4rPZ3ZuBYOcSycUpcb OZFnDZNy471V9xfpaL5/s0BE8PfxuI4QH9NE3zK7slXA9njr54SXGKFqPQrKnYu2RJ1b 7DiiBjQ+ID2EgLSQPD6KUwZd8RfA7t6joc6cR7NT4mUftLSIdMf9E213AIpwxs8rYnVy RmrQ== X-Gm-Message-State: AOAM530b+FSCSax6ypq6G1bnXVrKvxo9JN0FKSrrQwra1VU1p4zNpeS0 oDVIruBCSe6emyJEvXIanUkHQRq26ww= X-Google-Smtp-Source: ABdhPJxguckFJVuehvUPfv5Z4ne+B+J8hpDQPMORlOZBAnmOKpuBayGBxMv/UZv3+T/0VDauE1Ulow== X-Received: by 2002:a17:902:b116:b029:d8:f5d7:5fe5 with SMTP id q22-20020a170902b116b02900d8f5d75fe5mr5293223plr.48.1606451277641; Thu, 26 Nov 2020 20:27:57 -0800 (PST) Received: from bobo.ibm.com (193-116-103-132.tpgi.com.au. [193.116.103.132]) by smtp.gmail.com with ESMTPSA id u85sm6106167pfc.124.2020.11.26.20.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Nov 2020 20:27:57 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Fri, 27 Nov 2020 14:27:50 +1000 Message-Id: <20201127042750.763038-1-npiggin@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Subject: [Skiboot] [PATCH] core/cpu: fix next_ungarded_primary 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" next_unguarded_primary dereferences NULL CPU -> UB -> infinite loop Fast reboot works again after this patch. Fixes: 98f5834253c7e ("cpu: Keep track of the "ec_primary" in big core more") Signed-off-by: Nicholas Piggin --- core/cpu.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/cpu.c b/core/cpu.c index ff0442a8a..d30bef8e0 100644 --- a/core/cpu.c +++ b/core/cpu.c @@ -823,11 +823,9 @@ struct cpu_thread *first_ungarded_cpu(void) struct cpu_thread *next_ungarded_primary(struct cpu_thread *cpu) { - bool is_primary; do { - cpu = next_cpu(cpu); - is_primary = cpu == cpu->primary || cpu == cpu->ec_primary; - } while(cpu && (cpu->state == cpu_state_unavailable || !is_primary)); + cpu = next_ungarded_cpu(cpu); + } while (cpu && !(cpu == cpu->primary || cpu == cpu->ec_primary)); return cpu; }