From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87CA73242D7 for ; Tue, 9 Jun 2026 23:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781047692; cv=none; b=bR6OoWVr4q1qzjTjGZflv0upc4j9aXzjcX/lqGumM75Nu/Y6eABPmJ5b6Bm7grnGqwXs+5YLUN7cSPVsTeR7ldxcls/cbFr+WPwTGeTwGeMsFjoAtAETGSbBaabQ39C7lpmor2IdT1H7HjRio4pVwqtFwfVDrwvrGdKGG/CXSMY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781047692; c=relaxed/simple; bh=d6DqvulKo66+SP+Xu5s6VVjmmIpDG6NY0uSfY9ztMVg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K958M3l8tVy88Ftl9vm7Xj5p/WaQ1WXo6U5QObXKpRfkdfw5ZXRs5tLk1t3aD56ykVXski/0VTznbU01oINsYD+spnCPjFGlP8gHLEqg7WBbbhxHdXf4qlDDvln//M1Q/A/DBYKvkjEXWk16/1h4fPD4tC6eTycH8JSwGy5ySXs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=fHbfk5f3; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="fHbfk5f3" Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id 030AD40E01B5; Tue, 9 Jun 2026 23:28:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id IVKSZ_-RKdP5; Tue, 9 Jun 2026 23:27:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1781047675; bh=Jyy0cgVEHJz79x1VRwQPQvW60lleqZ4VtsOAm/SggGI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fHbfk5f3MpJBveELjXNMdunAo6qEYatlsafogyrYbHWe2V2mEVXmzwbsLca7qBVB2 T9Aw0qP6+K6DriR4N2ykhjbkZBPl7mTm9UTViH+EDejIf+zNJZNqr//yepmrPZnNmX 42gIlh6T/ChXyJenGW4kyp5KYWWx7UgppmIlAp0lZ/oOH0OID5Rrh5zTyO8ferkvqs 4Nd8F6vrzOJajH4yp+rWhCH9yc9VDbkGDYf7AVHsTjIJASAbPB2p2sU8h515F2dQry ikVDaZ3tpW/0Ros6t+35adU0oiIw6sf83FloE0fARd+KESvh7r+KhJ49jpjFoaG0Za kw6b3uc2uDMiDZ7OxyWHm29ViBAWCyt7Y07f4Ngm5EgX+39TGCztjJq3nMmTWSaZcc od/zf0zjR1SCep/1Dsc5u10Bndgn/WrILEnNpGjH4CkDYerrznIP4wVRFcmr49lIJ3 vUYm6XPTNdARuZgFgaMDRXffnXbm740xGyReWzbYRnC9bU6Axby6G6bqlaXGZZw7PC EBHE2o3R+xjjk8bjrQfO8w6bOJalX1VTdbWuHlOJid0WpYKbqKc4tE/FKdSco/SBbK HKDHbSWspQvilpW9gP76+3EFS9oR1SrpCbaYZA7fCyBKWrS/OIDFWVZBnMyH7n0hui p2dlpaUDsk1BfuShPvXgk0oA= Received: from stx.tnic (unknown [IPv6:2600:1700:38ca:c00::3a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 3A98F40E0031; Tue, 9 Jun 2026 23:27:50 +0000 (UTC) Date: Tue, 9 Jun 2026 16:27:46 -0700 From: Borislav Petkov To: Jim Mattson Cc: Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org, yosry@kernel.org Subject: Re: [PATCH 1/1] x86/CPU/AMD: Avoid racy updates to MSR_K7_HWCR in set_cpuid_faulting() Message-ID: <20260609232746.GAaiihcp9EItlpkCB4@fat_crate.local> References: <20260609211611.466231-1-jmattson@google.com> <20260609211611.466231-2-jmattson@google.com> <20260609214115.GAaiiIexPUw8aWoT8A@fat_crate.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Tue, Jun 09, 2026 at 03:08:22PM -0700, Jim Mattson wrote: > Yes, I'd be happy to. Thanks! I haven't heard that in a while - it is usually grumbling :-P > Most HWCR updates are in init code, so they should be fine. Should I > call the helper from init code anyway? Pfff, looking around the tree, we've accumulated a lot of HWCR pokers... I'm thinking perhaps we should leave the obviously non-problematic ones alone for now and convert only the problematic ones at first and then slowly, convert the rest. Otherwise, that'll be a bunch of patch churn at once... > If this can race with boost_set_msr_each(), You mean if someone echoes into sysfs to toggle boost and yanks the module at the same time? Pff, I fail to see the valid use case here but I won't be surprised. > then the bigger problem is that boost_set_msr_each() might set the > boost-disable bit between the call to cpufreq_boost_down_prep() and the CPU > going offline. Offline? I think that's the module exit callback acpi_cpufreq_cpu_exit() which calls it. /me greps some more... Uff, that's hit down the cpuhp_cpufreq_offline() path which is the hotplug callback. > I couldn't convince myself that cpufreq_boost_down_prep() was always > called on the CPU going offline. The call to boost_set_msr() on the > current CPU suggests it is, but the 'cpu' argument suggests it isn't. > If policies are shared, my reading of __cpufreq_offline() is that > cpufreq_driver->exit() [which calls cpufreq_boost_down_prep()] is only > called when the last CPU sharing the policy goes offline, potentially > leaving CPB_DIS set on the rest. Yah, I see it the same. Unless we both are missing something, this looks broken and prolly no one caught it because we're using amd-state now. And that thing doesn't even touch CPB_DIS but does this pm_qos stuff in amd_pstate_cpu_boost_update(). Dunno, do we care about a driver we don't use anymore... maybe, but low prio... > Anyway, since boost_set_msr() is called from both process context and > interrupt context, perhaps I should use the helper in boost_set_msr() > as well, just for consistency. Yah, stick the call in the case ...HYGON/...AMD: branch and should be good. I can test it then on some machines here. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette