Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp90671rwb; Thu, 12 Jan 2023 03:58:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXsTsNmz0D2TtUoefAzv9OvgsizigHgYXNPLez7bL52ZLbpiiSpG9j86ziBtWVxVefjEBu+B X-Received: by 2002:a05:6402:2944:b0:499:46c0:1269 with SMTP id ed4-20020a056402294400b0049946c01269mr15189272edb.14.1673524680063; Thu, 12 Jan 2023 03:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673524680; cv=none; d=google.com; s=arc-20160816; b=PCeDY8+VZlY2q3o9EoYQwcBJ+XlX3Es347j26QdfU8K9tGTAQP1toQ/ZQhPlF6hAd/ Bc4uqSwywLL7AihDMJ8f4c1s2KaOMlYJHxQk9n501+JvCi2Hq66hQvvapIl6ogiBvU+M fh0WtecTsqD4HXI4fore3elcNBFWwf9Q9hohRhakYq/2goxDVSJ9jgisSjLsorch2YTS wKLDiKc05HowXPyP16cZUliONAvMZzdSIfICFEI4j0KyX1T0bSrHXHKSVU9SYGyQOTeT dN+q5MTPsmruEkEA5+7Ldm2L1/nFhdeFYnF/V+KeSDSuHlMjpBdV+6E/XIJpx1nvKImm qjVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0vQOVZuKQjRWQ/e7isoLIfI6wGC5c5xNgWFk0olFibk=; b=KPwWNnkdfBA5Mca9vv2g+GWjxahpDSacEP9aMAkFMtuDRR9RWyf5FisEoUW9+xk6rs hbxwMvba4pf5An9l2hHz+zoAsEzZgBKj9fc8ItAIJUT2Nqbr/CwpSv48k3hiagV3/kxq dalZAgxK69qimCJcYjyF9pQKldcX6+mskU3tim0yuA9wGBnySYqUr7usASg/0TX5L7z6 GnMb4acFqQcbuTn/3V98OJN0pqp5O88fYm+spNrTNH5X5oagnhojvP4CHPhl6w6TkBaY WvQTQVchxJKbB18OeKGDvuK23nA5OVoPkVOBkLFxLlf5pueWC2kZrDmcGFYfwt5aeBzW rgnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=p3NLvpJQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a056402254700b0045ad02bb8fbsi20484726edb.290.2023.01.12.03.57.48; Thu, 12 Jan 2023 03:58:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=p3NLvpJQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232576AbjALLUl (ORCPT + 49 others); Thu, 12 Jan 2023 06:20:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238814AbjALLTt (ORCPT ); Thu, 12 Jan 2023 06:19:49 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF0C13DBDD; Thu, 12 Jan 2023 03:12:07 -0800 (PST) Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 926031EC05F1; Thu, 12 Jan 2023 12:12:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1673521925; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=0vQOVZuKQjRWQ/e7isoLIfI6wGC5c5xNgWFk0olFibk=; b=p3NLvpJQL38wQx7laaSRDtG1IyQic4qNmIwn9kOtsfROkX701b3CXKkbs/R5FZTjuoprFS iTfWt7+i2spQAZ2yqVr7N3o52tPpqVl79crY84UzZUYQ6s31KIMeQns/7ea/LCEPoBpQkV yJ+FpQWMwUGgrzqcfkvOT0BfHJd6IXI= Date: Thu, 12 Jan 2023 12:12:02 +0100 From: Borislav Petkov To: Alexey Kardashevskiy Cc: kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Venu Busireddy , Tony Luck , Tom Lendacky , Thomas Gleixner , Sean Christopherson , Sandipan Das , Peter Zijlstra , Pawan Gupta , Paolo Bonzini , Michael Roth , Mario Limonciello , Jan Kara , Ingo Molnar , Huang Rui , Dave Hansen , Daniel Sneddon , Brijesh Singh , Arnaldo Carvalho de Melo , Andrew Cooper , Alexander Shishkin , Adrian Hunter , "Jason A. Donenfeld" , "H. Peter Anvin" Subject: Re: [PATCH kernel v2 1/3] x86/amd: Cache values in percpu variables Message-ID: References: <20221209043804.942352-1-aik@amd.com> <20221209043804.942352-2-aik@amd.com> <61fde9ac-e24f-c765-a9a8-91fac60b9cb3@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <61fde9ac-e24f-c765-a9a8-91fac60b9cb3@amd.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 12, 2023 at 04:21:28PM +1100, Alexey Kardashevskiy wrote: > "that function" is set_dr_addr_mask() (btw should I rename it to start with > amd_? If you really wanna... I mean the code is already doing AMD-specific handling but sure, it'll be more obvious then that arch_install_hw_breakpoint() does only AMD-specific masking there under the info->mask test. > If it is out of bounds, it won't neither set or get. And these 2 helpers are > used only by the kernel and the callers pass 0..3 and nothing else. BUG_ON() > would do too, for example. Yeah, we don't do BUG_ON - look for Linus' colorful explanations why. :) In any case, I think we should always aim for proper recovery from errors but this case is not that important so let's leave it at the WARN_ON_ONCE. > imho having 1,2,3 in the code eliminates the need in a comment and produces > the exact same end result. But since nobody cares, I'll do it the shorter > way with just +1 and +2. Yeah, the more important goal is simplicity. And that pays off when you have to revisit that code and figure out what it does, later. > Sure. Out of curiosity - why?^w^w^w^w^ it reduced the vmlinux size by 48 > bytes, nice. The same answer - simplicity and speed when reading it. That if (per_cpu(amd_dr_addr_mask, smp_processor_id())[dr] == mask) is a bit harder to parse than if (per_cpu(amd_dr_addr_mask, cpu)[dr] == mask) Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette