Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1000204lqo; Thu, 9 May 2024 01:29:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWH6NQyUee1vHV+3wDOOBYv76J5tIDJQVgyOK6hh28i2JYBJjr/AY2V8f4+9cR+Lw5tFGUYARy6Gq7XtEy2VOznFYN6hFnUB3OVjh6lvQ== X-Google-Smtp-Source: AGHT+IFAsTjGo1vi0Tc9DuGKG5eSr9ttCMxn02z7wqnD0xY3l5V7wd1Odyq6swaTeFcLZtXZMck/ X-Received: by 2002:aa7:9e8b:0:b0:6e9:38d0:5019 with SMTP id d2e1a72fcca58-6f49c0c0c8cmr4902139b3a.0.1715243363390; Thu, 09 May 2024 01:29:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715243363; cv=pass; d=google.com; s=arc-20160816; b=pefc+vCXpiS9CPOShfhOTFb7H6z6u/In8sjBDHFFHMLHoODqGWcJPrCECuWsvcoCN0 B1agX+50oPBrdTL4Zfb4efTHQnciq8CbqRDOYUtCbC8JagHtZcIaRKScaGg8QSIjGYLN PB2CXSADdrP7FRyr6m7NdW4qE4uvVqFbEU3TKtuKd+fIIn0MRdISrbSY+QjQ+UKBdx+o xjhWr6c7GUsIrhKuRoj1n/el3F5RCtgXQo4Exy8k6TPxP6shhJam8VxLdnBcABkqRKwL +8ZUOZVZRF/j0UYWNg08zUqyl25NrI54wW0nk283AQJRVvGoKkaYMil9MbsKIpGoDYFV h67A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=L9OBZbvS0WP26j2hKZQO9jjPKnz/pC2a+sctlFlJyyM=; fh=Mj1CqGSuQ/WAybtnu/yi6O7+x0cWvy51DWcl0bkvJVQ=; b=0Uj2PTHhk1Z4b7t5tIC7HrApP5udkkZ6F8aTki7MPhdxa4mXAHMfFV7IVJcGQxd4V/ mHQHkOP/C6rIkBQeyV3VKQIsUhix1Iy/7zwmTFuMX6xxPObPSEzbYv+4iak7RgFg9NSJ vzRSzAVuNYxvuMpeo0pDkYuoRQRBX94FYPZIOCA8Hf/YWq+wViR0w2BoiQ/4APeq01QX N4O7uHe75Si5Dm88CXIc36fnQzJBP7Q8++HJn627EDbpkqGGXm+wKsjdt27F5t2Xy8ba LTED8IrgTBjkMnUlKI2taRqY0+aEVr6fdHYRnrlUDZmkMJ8t/RlQdDu1qPOEQnU3JejL 4u5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=Wa44uraL; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-174283-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174283-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2a8f6b0si1012811b3a.87.2024.05.09.01.29.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 01:29:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174283-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=Wa44uraL; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-174283-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174283-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7A19A284E4B for ; Thu, 9 May 2024 08:22:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 292AE149DF1; Thu, 9 May 2024 08:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Wa44uraL" Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 2461414A0AA for ; Thu, 9 May 2024 08:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715242910; cv=none; b=U1LzPuH+JoJ0goGBMS+7TQgOet30EFL97Ikh4Ab+F0VsNrCwAu/KiArKUwNRn2/UN58ddkmih3exPJ9u2+fczN70QTIuahbdXZsNTu47deA48oAd4KS7cXhHO5gdqwLEZnK81GYvixiJtltjqbPq5PGQMPQ59Ydt3XabLpPhjMs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715242910; c=relaxed/simple; bh=IXqoH3hnQ35zr7yeunibtDNWu/kksJKf+G6m/To04QM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BDaVPV8Xxce2b3Tp6SofbN6RrjduSxhB3m1EL8llr0nihmf4MTw27NoRu9uYLA4YsQwN9W5B2aVKNfVGaxFJj9kRD6XZAul+qA01U8SqAgNB8yOimfvdBlVDHFgHgOg63OEIPmVSZt8/8DAboU7qlqD7kCu3Bpu7zSDxIiFXWGg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Wa44uraL; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-41c7ac6f635so3733035e9.3 for ; Thu, 09 May 2024 01:21:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1715242906; x=1715847706; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=L9OBZbvS0WP26j2hKZQO9jjPKnz/pC2a+sctlFlJyyM=; b=Wa44uraLCCwKvAboiaLFGAQe6hi2rSBb2mhvrZhIoWItBTJ6QGn1RDrPuKLfBPOQgV Z0tAuJDH+TgULe9dnvtb9KyupCj5mGNdQ5FnkERz+AI1Sp1OeP04m5LtCdgLZhLR1hnt cMFL/kWN5F8Q1UfERy3mnwaXBtEqQp0fHX3hop63meSMLoAVevKdfrDlTtsWgQJklbQz bmrhYnK7df0cPIrnuH4OhZ272+D/k8TUb4L4SDrgndG3qqBZq5ANAQ/jpe6wekPIqcMh YkhfMoMOGW2Bk7FQJNvoQkSBwFNXPLtgz27rqLvn+zHtfKUKhoQxl0cazyg4OyA5gt6x 8Xyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715242906; x=1715847706; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=L9OBZbvS0WP26j2hKZQO9jjPKnz/pC2a+sctlFlJyyM=; b=MNF0Q+3dZQhxIqkD4GWh4InphBJ4ga2gPIb1+2eaSt1MqwQG0Ycz1Kl1lFbmnYz1o/ v4dfJYnci2WiywnhF3DIOasP/AT80ttd+4Q+IMDl9TCKi/KfY3yck5hfwrmh2dFK4cyL IIfhIP4R+yki3Zq4EPhB5ey9rL4rl0nyi+hvEsdJa+M7870DnpAbSNbB40aqyYD+H1Jt 38jOE3/jMoi6wUypK3zMrXwH7r9546HBqQyeFvC4jG6sKiI/RkqXigsHXbj+sL+7TSyb G8idtfIOeToJa1mxZdCRt07TJ1RXzLTDJK5tCrejzI+G0tCDiLDscE0fcC/IOyBgQbkd jHNA== X-Forwarded-Encrypted: i=1; AJvYcCUPvcaPlVwskl7fRirAcnEBo21gVzAOEyqHTwnVBE2yV1BPiQoS245S4KH2dEJU9tkg320euV6FltKEB8hTXB4g5NQH0tjiO57RZsgp X-Gm-Message-State: AOJu0YyTOBoa4Ug9UAmLGuHn64aVJx6Y/HYSCKKQe9SlOb9NxrZJBS6n 4mtuWtAEpLD08UcMb8YGoHw1vb7N7MnRNh6Er3eTKBF0dkktlS6l79YN+KYF5Wg= X-Received: by 2002:a05:6000:136d:b0:34c:5e02:7875 with SMTP id ffacd0b85a97d-34fca433f91mr5870618f8f.7.1715242906276; Thu, 09 May 2024 01:21:46 -0700 (PDT) Received: from ?IPV6:2a10:bac0:b000:7315:9ae2:bce:2143:58f1? ([2a10:bac0:b000:7315:9ae2:bce:2143:58f1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502bbbc3e4sm1025016f8f.108.2024.05.09.01.21.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 May 2024 01:21:46 -0700 (PDT) Message-ID: <60ddec81-5102-4984-848a-ae3adb8c4c38@suse.com> Date: Thu, 9 May 2024 11:21:44 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/3] x86/bugs: Add 'spectre_bhi=vmexit' cmdline option To: Josh Poimboeuf Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Linus Torvalds , Daniel Sneddon , Pawan Gupta , Thomas Gleixner , Alexandre Chartre , Konrad Rzeszutek Wilk , Peter Zijlstra , Greg Kroah-Hartman , Sean Christopherson , Andrew Cooper , Dave Hansen , KP Singh , Waiman Long , Borislav Petkov , Ingo Molnar , Maksim Davydov References: <66327dcf87284a09ed17ac24227695ea3ba1f287.1715059256.git.jpoimboe@kernel.org> <20240509052447.kwdlruqad7r5h4pi@treble> From: Nikolay Borisov Content-Language: en-US In-Reply-To: <20240509052447.kwdlruqad7r5h4pi@treble> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 9.05.24 г. 8:24 ч., Josh Poimboeuf wrote: > On Wed, May 08, 2024 at 06:10:21PM +0300, Nikolay Borisov wrote: >>> @@ -1659,19 +1662,22 @@ static void __init bhi_select_mitigation(void) >>> return; >>> } >>> + /* Mitigate in hardware if supported */ >>> if (spec_ctrl_bhi_dis()) >>> return; >>> if (!IS_ENABLED(CONFIG_X86_64)) >>> return; >>> - /* Mitigate KVM by default */ >>> - setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT); >>> - pr_info("Spectre BHI mitigation: SW BHB clearing on vm exit\n"); >>> + if (bhi_mitigation == BHI_MITIGATION_VMEXIT_ONLY) { >>> + pr_info("Spectre BHI mitigation: SW BHB clearing on vm exit only\n"); >>> + setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT); >>> + return; >>> + } >> >> nit: How about setting CLEAR_BHB_LOOP_ON_VMEXIT unconditionally, then >> afterwards checking if MITIGATION_VMEXIT_ONLY is set and if yes simply >> return, that way you don't duplicate the setup of the VMEXIT code > > I think the duplication actually makes it more readable. In both cases > it puts the setting of the features together along with the > corresponding pr_info(). Right, my suggestion also meant that setting + pr info will be together, unconditional and if MITIGATION_VMEXIT_ONLY is set we return early, without setting X86_FEATURE_CLEAR_BHB_LOOP. In any case it's a minor remark, feel free to ignore. Reviewed-by: Nikolay Borisov >