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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 928E2C3DA4A for ; Thu, 8 Aug 2024 17:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=diwD1iCrpHXumZkgAMloBVGIf2kIwgitsF/BakIzCjE=; b=RUA0J0Jk/+U2VenTD4sPl3sx/g cyGrKyRNyjxqeUhUYJkJRM2WGkpCbGtGi9zQVUBjfr/+WClq38Vkpeo5lFmxLCPza37cWh9Auufm6 bA9TJlDNDkY7RsnAsTUpUiw9J9jM5FomXIbEzXVpn/d5nHQKMoxq3jhkBSCs445WeMgsl3gz/WgFF 6ejIU4oJ+5sLee5Vr92QGxXGcrKmQ0BTfSrrvpV4A/gGuVAhPldgfnmt9MTAV+2HDfq3hcHJKClRa gnZfTVmpNMEoem3m4RgSnQlLS5G3Eahe1/dc+flxG/iRKFehbn+y/21hbSsdv+YGR1a8tq6lYreHu mEKF4k2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc736-000000097Gi-1BOy; Thu, 08 Aug 2024 17:35:40 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc72W-000000097Cw-2Rxn for linux-arm-kernel@lists.infradead.org; Thu, 08 Aug 2024 17:35:06 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-70d199fb3dfso1006687b3a.3 for ; Thu, 08 Aug 2024 10:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723138503; x=1723743303; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=diwD1iCrpHXumZkgAMloBVGIf2kIwgitsF/BakIzCjE=; b=MMYPhmqhKihhKXDKl4Gv8vW+TedEMBFUrfPGJybVtbPNsQ0AljsxaKQyWARMQQiXwT UDAfm/Vs7Ph2WyijWNinRMr5Nn9dqcM1/gO4TkYzdb/urPTwihBDWWFVIN4EMUHYIbmg FqEmP9s/n3uh3ZmarcbhTT2kx0Q+F+jL0JXEYPTyPOeyWeWGvQK5GDxd7WA4C8k4jH/o 1902djKXOeKk85hZ7MdZ6WO3cWFyf0mlZhtc/BVvq/PyWR/FEbGDonWkIP0tsWLEmneX x40rl0SJZA1prwqmRtqtUE4OK5fT6kiMNllyoiTmiA+c/wutHobWyvDJDiTB7iqq5mfw KMwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723138503; x=1723743303; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=diwD1iCrpHXumZkgAMloBVGIf2kIwgitsF/BakIzCjE=; b=OCkfHUEysQa0rFPHfDuJR82PJRbcAugt4JdKfK2HwlsGjmpZtBYs2iB0ZY40lo2z15 9SOXcS3/A4KMYFxqXSYRo9oyGoYt5FNbJXV02gqwbMaBCUJxV5OgAIOQfJzvhe8hFP1I 8wRlNjToMs6ChgK9TYcXB+RPtMZ+fEr7aXRRgs7hQRj78IcdGRPoz+NdH6i9yy08cdFL mMhVmBvOXuYrvFCAsWop2VLhLrq6rCvHQUTYaF0nf+yzND187JKwwae7O/0nnnoDIBH/ kguBwtoA90F3wSpM36w+LIPHRmjmevg3btgDaNjqnhB6pCGQnYvGc/HGXd18mP5QxvzN 8bhA== X-Gm-Message-State: AOJu0YxCz/dxu1Q8FW6bi3rqgRdXjWSVBpaJFC1C9xPwSNbqH9Ap1zk5 fCUYGOcACNRuyhnm1dCqq7FOfGnk7bVNM31L28I58h0Gz47cs3lU X-Google-Smtp-Source: AGHT+IE51YiR1kStYj12rpo+NUS09VqpSsVkvxnS3g7oMwKAgam1hLO0cnWbZ/U3GDmrQEv657ePjA== X-Received: by 2002:a05:6a00:2d95:b0:70b:cf1:8dc9 with SMTP id d2e1a72fcca58-710cae7174bmr3204310b3a.25.1723138503114; Thu, 08 Aug 2024 10:35:03 -0700 (PDT) Received: from localhost ([216.228.127.130]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-710cb22f29asm1363716b3a.63.2024.08.08.10.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 10:35:02 -0700 (PDT) Date: Thu, 8 Aug 2024 10:35:00 -0700 From: Yury Norov To: Gavin Shan Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux@rasmusvillemoes.dk, Jonathan.Cameron@huawei.com, salil.mehta@huawei.com, shan.gavin@gmail.com Subject: Re: [PATCH] cpumask: Fix crash on updating CPU enabled mask Message-ID: References: <20240808040808.647316-1-gshan@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240808040808.647316-1-gshan@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240808_103504_650707_98DD9783 X-CRM114-Status: GOOD ( 19.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 08, 2024 at 02:08:08PM +1000, Gavin Shan wrote: > The CPU enabled mask instead of the CPU possible mask should be used > by set_cpu_enabled(). Otherwise, we run into crash due to write to > the read-only CPU possible mask when vCPU is hot added on ARM64. > > (qemu) device_add host-arm-cpu,id=cpu1,socket-id=1 > Unable to handle kernel write to read-only memory at virtual address ffff800080fa7190 > : > Call trace: > register_cpu+0x1a4/0x2e8 > arch_register_cpu+0x84/0xd8 > acpi_processor_add+0x480/0x5b0 > acpi_bus_attach+0x1c4/0x300 > acpi_dev_for_one_check+0x3c/0x50 > device_for_each_child+0x68/0xc8 > acpi_dev_for_each_child+0x48/0x80 > acpi_bus_attach+0x84/0x300 > acpi_bus_scan+0x74/0x220 > acpi_scan_rescan_bus+0x54/0x88 > acpi_device_hotplug+0x208/0x478 > acpi_hotplug_work_fn+0x2c/0x50 > process_one_work+0x15c/0x3c0 > worker_thread+0x2ec/0x400 > kthread+0x120/0x130 > ret_from_fork+0x10/0x20 > > Fix it by passing the CPU enabled mask instead of the CPU possible > mask to set_cpu_enabled(). > > Fixes: 51c4767503d5 ("Merge tag 'bitmap-6.11-rc1' of https://github.com:/norov/linux") > Signed-off-by: Gavin Shan > --- > include/linux/cpumask.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h > index 801a7e524113..53158de44b83 100644 > --- a/include/linux/cpumask.h > +++ b/include/linux/cpumask.h > @@ -1037,7 +1037,7 @@ void init_cpu_online(const struct cpumask *src); > assign_bit(cpumask_check(cpu), cpumask_bits(mask), (val)) > > #define set_cpu_possible(cpu, possible) assign_cpu((cpu), &__cpu_possible_mask, (possible)) > -#define set_cpu_enabled(cpu, enabled) assign_cpu((cpu), &__cpu_possible_mask, (enabled)) > +#define set_cpu_enabled(cpu, enabled) assign_cpu((cpu), &__cpu_enabled_mask, (enabled)) > #define set_cpu_present(cpu, present) assign_cpu((cpu), &__cpu_present_mask, (present)) > #define set_cpu_active(cpu, active) assign_cpu((cpu), &__cpu_active_mask, (active)) > #define set_cpu_dying(cpu, dying) assign_cpu((cpu), &__cpu_dying_mask, (dying)) > -- > 2.45.2 Thanks Gavin. I'll send a pull request withing this week. Thanks, Yury