Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp694358lqb; Wed, 17 Apr 2024 08:14:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXgjkSYaOBmAZdJCbOLmyt5ip3PbTxl3+HqOoSZ40EXzoyXn8BMvhZT1sWT+i2WB9OY9ZVv9w9pPWGWJZH7jjQ7AqNDVd+lEJMvWwOLGQ== X-Google-Smtp-Source: AGHT+IHYJRQ9+0Ah/8vI8TkmQIscQ359co64r+/c6P/k11Juzg9RpQPWv4rks2kPAcigj/JVIUQr X-Received: by 2002:a17:90a:5289:b0:29b:c31:1fe1 with SMTP id w9-20020a17090a528900b0029b0c311fe1mr7778086pjh.10.1713366897069; Wed, 17 Apr 2024 08:14:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713366897; cv=pass; d=google.com; s=arc-20160816; b=kLXesxMw38idsrj9cjaF7mijundaXAuUoHpdXptzcBhN9KzsIFwxJ4FNKiPop977zv nm5R72ONH0yv8r3QMN/w+xZDgb0Km6WaUG236AFnsrXF7GyI1ijIhj8RAV/9t00eUQAP Vh+i5MLj7UHdrPCcMXatHF+l9yDm8Xm5CUUOLt0lzkTc9auqtDMDiFZ2TXUoYWvo73DV fFSY2QK9Lz5dsCi3dPrL1FFtzdTp6Tg6MNfx1GWQU/99/XQ9NKIYn5Pyu2PGNC40ZAu+ rhM9YE3FCvhVJyu6yiEHBp1UmXFzZb4bcn177mGLzLqffhTEfM7gPV5mgAO5zzXTWzXb 95ZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=kk0Avlz1XVcQzGK56nbqwv1KbNP6HskfmFpfXJ3Bcq0=; fh=QHP6WNV2vqmmmVBwYZJm+aUjNiYQ52974lw1nxvUP5E=; b=JWGJn+xGBM5EB23sPimf0Gv7dUS3MHflS96FAV18tq4RlcbAwAhEjCEAYRxJzzDSh+ SGLKQ7dSOCaWWwOYvQYgg2wY9tpksHhpHdvN5dfmNX6UI+0rtW1QiqZ7fNACpPPRh37k zUDMqkJf76Tqq+n9tsQAjgehlJJiD7lX1IxnSIbWpG28oL0VWgHiu8wNzqStdC7O6NG1 WCazU7pZm3GVhMurc7+wLz0ff7iW+2BX0i9Qy71CFkQZmY7dp1mSvQrljSmj2DufNQ5L PVDqn2pNPrUFVx/nyKyjOCQak6elm//ddDGfUG33KG5o8XaHzh3fC4NGXHJN8NbOoeqw gVDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=elsNO9Cu; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-148774-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148774-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a16-20020a17090ad81000b002a2d0de4884si1442960pjv.101.2024.04.17.08.14.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 08:14:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148774-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=elsNO9Cu; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-148774-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148774-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.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 B822B2816AD for ; Wed, 17 Apr 2024 15:14:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AC95A146D54; Wed, 17 Apr 2024 15:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="elsNO9Cu" Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (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 373AF146A98 for ; Wed, 17 Apr 2024 15:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713366873; cv=none; b=qoPdWIJYg9Kb28cAK116WZtNS44VNTuk6j0ayLcKGOweR5uZ5SRJYFAWGVw1O6fVesDkSic9Nk/qfHaRnA/AhI28hjAOht6ufNGqDbvT1FeYknbKfoqHVfhOzIDLmYl80pCv4HRsb/EKH2xf47Kb93G3FNnaCpNk0Ah7Eir5NZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713366873; c=relaxed/simple; bh=wTRSuvaFOlksWT6RSV0fvqkoghiSJftMlavhyWBuFXM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=LAvQHwiPUisaase4wp8AF+95Z+LDt1z2M49uR0uulVogvZQPX12GPZFRirTTJncIQVpicHB/hyxvjnrvDxny30JtHPEJ18msx1q+0mvoJOntbxi2I+VfKf7KL9YlL/8kvORX+cYZsD9Hi85YccxbJtbxgktUsJiMWRp8DXJ6oc4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com; spf=pass smtp.mailfrom=cloud.com; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b=elsNO9Cu; arc=none smtp.client-ip=209.85.219.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloud.com Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-69b5dae6a64so6922066d6.1 for ; Wed, 17 Apr 2024 08:14:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1713366870; x=1713971670; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=kk0Avlz1XVcQzGK56nbqwv1KbNP6HskfmFpfXJ3Bcq0=; b=elsNO9Cu64OsQuw7mDBfIP3hFo53yxD8ivVOm1Ec61yJ80nLjz6Xy1sJeF9BshzBEV q2RzL8v7tMF2lWVObnEB+Jt3BIGVMA1k+xVgxdUCr6LBFKk+GuTDcbmsT5hQSqKLb5r1 Wi0BnKLAZkvDUMKh4RFtyF5Ki5J/WOgqsjKxM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713366870; x=1713971670; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language: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=kk0Avlz1XVcQzGK56nbqwv1KbNP6HskfmFpfXJ3Bcq0=; b=mVv/kRJ9ezZawoK3xb1zm3/xUwppc0EgudYxZnJZFOEziXNJoKNx/LKKg0cT6Yb8dr 2xOBW1d0Y457TQ/0Er+THyoV9k6Tj7xdQ8z3ydk9K4goNYN0rv2ULdTiGamS0YC5sGN7 J45uGdvV3IiUEQf8xKJwoiPVwm2HTRPPmgQyr4gtw0RiOnzVSuixKdpmiYrWCSzou6H/ hTWu9CT1VwKFtp9vsaWWxYZBB6YW1CH2cJshnRQX5mAnP3P/aRg8qFguDFUxH/Y3HoRo cDxn1wvnp3TFb2AioqLV6ZsXfmXIDytUZyXLhz4V4jWY+RC8SHsHfAOhJ3StCl37Qu+z 3w+Q== X-Gm-Message-State: AOJu0YzJxRbYeaMTf2m2NkvV/YhArgsKZWL+8rQHHWyjc0iDIAp+kmZE /6GMQDOWZDvDbY4RBYxlJXlMtSTXotDhz63Lb7kEc04ERw2BLAse2A2bz3bwyOs= X-Received: by 2002:a05:6214:30f:b0:69f:8e2d:c088 with SMTP id i15-20020a056214030f00b0069f8e2dc088mr8250791qvu.3.1713366870105; Wed, 17 Apr 2024 08:14:30 -0700 (PDT) Received: from [10.80.67.140] (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id d7-20020ad450a7000000b0069b26d7f061sm8378408qvq.99.2024.04.17.08.14.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Apr 2024 08:14:29 -0700 (PDT) Message-ID: Date: Wed, 17 Apr 2024 16:14:26 +0100 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 v3] x86/bugs: Only harden syscalls when needed To: Josh Poimboeuf , x86@kernel.org Cc: 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 , Dave Hansen , Nikolay Borisov , KP Singh , Waiman Long , Borislav Petkov , Ingo Molnar References: Content-Language: en-GB From: Andrew Cooper Autocrypt: addr=andrew.cooper3@citrix.com; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABzSlBbmRyZXcgQ29v cGVyIDxhbmRyZXcuY29vcGVyM0BjaXRyaXguY29tPsLBegQTAQgAJAIbAwULCQgHAwUVCgkI CwUWAgMBAAIeAQIXgAUCWKD95wIZAQAKCRBlw/kGpdefoHbdD/9AIoR3k6fKl+RFiFpyAhvO 59ttDFI7nIAnlYngev2XUR3acFElJATHSDO0ju+hqWqAb8kVijXLops0gOfqt3VPZq9cuHlh IMDqu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TEQz+N4hbKwo1hULfVxDJStE4sbPhjbsPCrlXf6W9CxSyQ0qmZ2bXsLQYRj2xqd1 bpA+1o1j2N4/au1R/uSiUFjewJdT/LX1EklKDcQwpk06Af/N7VZtSfEJeRV04unbsKVXWZAk uAJyDDKN99ziC0Wz5kcPyVD1HNf8bgaqGDzrv3TfYjwqayRFcMf7xJaL9xXedMcAEQEAAcLB XwQYAQgACQUCUuE2fwIbDAAKCRBlw/kGpdefoG4XEACD1Qf/er8EA7g23HMxYWd3FXHThrVQ HgiGdk5Yh632vjOm9L4sd/GCEACVQKjsu98e8o3ysitFlznEns5EAAXEbITrgKWXDDUWGYxd pnjj2u+GkVdsOAGk0kxczX6s+VRBhpbBI2PWnOsRJgU2n10PZ3mZD4Xu9kU2IXYmuW+e5KCA vTArRUdCrAtIa1k01sPipPPw6dfxx2e5asy21YOytzxuWFfJTGnVxZZSCyLUO83sh6OZhJkk b9rxL9wPmpN/t2IPaEKoAc0FTQZS36wAMOXkBh24PQ9gaLJvfPKpNzGD8XWR5HHF0NLIJhgg 4ZlEXQ2fVp3XrtocHqhu4UZR4koCijgB8sB7Tb0GCpwK+C4UePdFLfhKyRdSXuvY3AHJd4CP 4JzW0Bzq/WXY3XMOzUTYApGQpnUpdOmuQSfpV9MQO+/jo7r6yPbxT7CwRS5dcQPzUiuHLK9i nvjREdh84qycnx0/6dDroYhp0DFv4udxuAvt1h4wGwTPRQZerSm4xaYegEFusyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 17/04/2024 12:02 am, Josh Poimboeuf wrote: > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > index ca295b0c1eee..dcb97cc2758f 100644 > --- a/arch/x86/kernel/cpu/bugs.c > +++ b/arch/x86/kernel/cpu/bugs.c > @@ -1678,6 +1687,21 @@ static void __init spectre_v2_select_mitigation(void) > enum spectre_v2_mitigation_cmd cmd = spectre_v2_parse_cmdline(); > enum spectre_v2_mitigation mode = SPECTRE_V2_NONE; > > + /* > + * X86_FEATURE_INDIRECT_SAFE indicates whether indirect calls can be > + * considered safe. That means either: > + * > + * - the CPU isn't vulnerable to Spectre v2 or its variants; > + * > + * - a hardware mitigation is in place (e.g., IBRS, BHI_DIS_S); or > + * > + * - the user turned off mitigations altogether. > + * > + * Assume innocence until proven guilty: set the cap bit now, then > + * clear it later if/when needed. > + */ > + setup_force_cpu_cap(X86_FEATURE_INDIRECT_SAFE); Following on from the (re)discovery that X86_FEATURE_RETPOLINE is a poor name given what it *actually* does, can I recommend s/SAFE/OK/ here? This flag really is "do I want indirect branches or not", which - as noted here - is more than just a judgement of whether indirect branches are "safe". ~Andrew