Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp598718lqb; Wed, 29 May 2024 05:33:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMLSIv8nwXkfdSQT0xgWT1b/bxFA0ATz4EAHMs0utmIh2szjY9+tdqAV5CqKK0LsQV6wlCZUjINBi44blVQBAICIKr8srbkAhJZzgDcA== X-Google-Smtp-Source: AGHT+IE5R6mbfxM/64ut7jpsqo0EQQvGi1Xsm0XUj0H8dahpBZjomAMSX7FwmU9JkgiNBs4KDu8L X-Received: by 2002:a17:907:39c:b0:a65:b36d:d6bb with SMTP id a640c23a62f3a-a65b36ddae2mr51908666b.32.1716986027337; Wed, 29 May 2024 05:33:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716986027; cv=pass; d=google.com; s=arc-20160816; b=RprOQPJRUii30IfUaSnKNT2Oo19xH5LctkI/KGiEof+DIdI035cNl0Kv+W/QfUbC4+ 6rqVWLERL6TuUvI+ZdnQNT1UgFzuXUk4owm3gO/N7wt9OZ8u8TzF4ySkucMSoT008aMk Tpms4Fl3s+MjzT96pNoLEqQKgyeOOUEYuGQjEOWZ/kcoOy3aOke3UOz+uUk1tZfp0Jh0 VmIZ9+Fgz+vHnGwVSD+miM4XjwJS4ZXN0giCEJI9E9vEThOxMjoFOnbjfI7ODoczQK8L T8KuxbZcxffZUH1uvk9LwTuL5vcyfqXH3G4BzhceuUAnBfnB7bQAkNVVlsSovOsbguXq KsAw== 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=Kjz4o7E9Vi+goRaYpgYsPsr72HU+LspMKlqcruc8gzU=; fh=giTJl6vdgJK94/6iAXqyQDFb/++3Xk3ZwPdbL/VAg5k=; b=ze83GKpzTK+HeqHcsRPgOH1Zlr09QHD1MB13urDyg04n/a3UdR1qWMAPDEUu+PGS6T OD5glV9zZ15Z5sDR0bZ69WynzZqfaHTtUjbyeI+qmv4tfr/m0dBlvQCI8XCHqie9wnO3 NT5jVIiT5Wi6zdoxtJ1pxCkXDiTHClylvfp4lOeH+gsImDCi1xqexT3dRK951M/OYe2B aar28JnfYJEuoaSx5Xj6Xofo+MeMJn8cwK4pOT4gm9T3QKbUsAotxKJB2EtLZqNYwSdm XTVbYwZzfUxJNbVbN0WVPi94mRzorNnhi9HhnyTMtxwSwqM4VskxK9qeN+HmezXH8Mte WrBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=NSR466NE; 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-194092-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194092-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cdd0dd4si616769266b.925.2024.05.29.05.33.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 05:33:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194092-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=NSR466NE; 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-194092-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194092-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 am.mirrors.kernel.org (Postfix) with ESMTPS id DF3541F21F67 for ; Wed, 29 May 2024 12:33:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B32EA181302; Wed, 29 May 2024 12:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="NSR466NE" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 F371313F45C for ; Wed, 29 May 2024 12:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716986020; cv=none; b=nLEsQ1USOOdLQGAD2ou6SGkpwZT46W6DIrkQoyYSnkm+4W7IySRpS2Gawr3JcyxBKZw44/ac6o1fuaghAYt9SMWd7zU39kJIo5YKXn3f/fsCY3g8UgKq9Te/ESDA/8V0zJn2oNpckJbovC/jyvk2QX5ZIb3079ZKml1AoKDsmI8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716986020; c=relaxed/simple; bh=Kjz4o7E9Vi+goRaYpgYsPsr72HU+LspMKlqcruc8gzU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=a8rGMg+/Taw4dnyFWS8/O1PZ2w3t/WhPQFp8FRbIuW14tdCbSX3uJMJ3J2DNzX2PhmKUbw0dJxte/CN+qM14UKFf5PahRjstIqtvZyBcPuXpjV/kwt894XEUK6mjAfdWK2/T4p7zqWXAsxQoD/nl/8fhFISpR2ylBetbNjB3AP0= 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=NSR466NE; arc=none smtp.client-ip=209.85.218.50 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-ej1-f50.google.com with SMTP id a640c23a62f3a-a626919d19dso152577766b.0 for ; Wed, 29 May 2024 05:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1716986017; x=1717590817; 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=Kjz4o7E9Vi+goRaYpgYsPsr72HU+LspMKlqcruc8gzU=; b=NSR466NEIO5ofKy5wZSHd2p2r5xA5rI/OqrcOuDiNQ1+oU5dh7jX1MlQHenETSvrpA tPHFfYQorYkF6ez6n1uhiIBBFlaUVdXFDgokV/c0YkSep76UHhvoislF7lbvcy7elKX2 oaZ+oNUk2/DC4qiJKeIxMiPeadm/9JinQlUTY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716986017; x=1717590817; 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=Kjz4o7E9Vi+goRaYpgYsPsr72HU+LspMKlqcruc8gzU=; b=uwgNtzkifnxc6HFY6fEYoLsIQ93ZDCFdLRxN9tznfE2sY8BoPAU++FtHlWQyKE9nbm 9lvMMf0DWpfW6E3UlVyQLpLNDYAa9lbHbF+VW12onKYjboSxToQU/iTAYY4PjVPwGiC1 e3Q6PD9Kn0pB3MQV3Xk89610dZ9tCuZM0rOX/4tvJW37VqVJnD0eb6AtIbPAnLzrPbbd H9X1brhHeT/8Pg1mVtAkhfCza4s6tbBeL8uPfESjvZaytqDysfFej/26ZcrXYFiTvINS VRnAoiETXfHSJIIQ70Cbag3/19wiOgqeEunIhjuhKeSi6zJM8pr+z7pyCBhlwXUB1XFF 1MBw== X-Forwarded-Encrypted: i=1; AJvYcCUeBEU+1ZHLwe50Al6Iph4/3TsVpTrzk35OP1dZvUo5ioCggStE0QQLt5D3291h1JEAgd/yJfVFVXgK9vUfUkoFKdmS5LKpfgwoTbpB X-Gm-Message-State: AOJu0YwAYA9nlvC6I+SLLRcocOmtNo6xgCqIdgurfgjnUSWljjsrEPHw e3/Q9/Hj/AnNfPWgZrqt6vbEkCqMENBElUX1eVSI5ZICT5dzcwswzy5aS3nFv58= X-Received: by 2002:a17:906:40c8:b0:a62:a48c:1123 with SMTP id a640c23a62f3a-a642d2775bamr178860766b.5.1716986017274; Wed, 29 May 2024 05:33:37 -0700 (PDT) Received: from [10.125.231.30] ([217.156.233.157]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a637386898bsm95138766b.220.2024.05.29.05.33.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 May 2024 05:33:37 -0700 (PDT) Message-ID: <55bc0649-c017-49ab-905d-212f140a403f@citrix.com> Date: Wed, 29 May 2024 13:33:35 +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: [PATCHv11 05/19] x86/relocate_kernel: Use named labels for less confusion To: Borislav Petkov , "Kirill A. Shutemov" Cc: Nikolay Borisov , Thomas Gleixner , Ingo Molnar , Dave Hansen , x86@kernel.org, "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , "Kalra, Ashish" , Sean Christopherson , "Huang, Kai" , Ard Biesheuvel , Baoquan He , "H. Peter Anvin" , "K. Y. Srinivasan" , Haiyang Zhang , kexec@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-acpi@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org References: <20240528095522.509667-1-kirill.shutemov@linux.intel.com> <20240528095522.509667-6-kirill.shutemov@linux.intel.com> <1e1d1aea-7346-4022-9f5f-402d171adfda@suse.com> <20240529112852.GBZlcRdI3oqBtjKxAV@fat_crate.local> 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 gNt25XTLdSFuZtMxkY3tq8MFss5Qnjheh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Fv4udxuAvt1h4wGwTPRQZerSm4xaYegEFusyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== In-Reply-To: <20240529112852.GBZlcRdI3oqBtjKxAV@fat_crate.local> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 29/05/2024 12:28 pm, Borislav Petkov wrote: > On Wed, May 29, 2024 at 02:17:29PM +0300, Kirill A. Shutemov wrote: >>> That jmp 1f becomes redundant now as it simply jumps 1 line below. >>> >> Nothing changed wrt this jump. It dates back to initial kexec >> implementation. >> >> See 5234f5eb04ab ("[PATCH] kexec: x86_64 kexec implementation"). >> >> But I don't see functional need in it. >> >> Anyway, it is outside of the scope of the patch. > Yap, Kirill did what Nikolay should've done - git archeology. Please > don't forget to do that next time. > > And back in the day they didn't comment non-obvious things because > commenting is for losers. :-\ > > So that unconditional forward jump either flushes branch prediction on > some old uarch or something else weird, uarch-special. > > I doubt we can remove it just like that. > > Lemme add Andy - he should know. Seems I've gained a reputation... jmp 1f dates back to ye olde 8086, which started the whole trend of the instruction pointer just being a figment of the ISA's imagination[1]. Hardware maintains the pointer to the next byte to fetch (the prefetch queue was up to 6 bytes), and there was a micro-op to subtract the current length of the prefetch queue from the accumulator. In those days, the prefetch queue was not coherent with main memory, and jumps (being a discontinuity in the instruction stream) simply flushed the prefetch queue. This was necessary after modifying executable code, because otherwise you could end up executing stale bytes from the prefetch queue and then non-stale bytes thereafter.  (Otherwise known as the way to distinguish the 8086 from the 8088 because the latter only had a 4 byte prefetch queue.) Anyway.  It's how you used to spell "serialising operation" before that term ever entered the architecture.  Linux still supports CPUs prior to the Pentium, so still needs to care about prefetch queues in the 486. However, this example appears to be in 64bit code and following a write to CR4 which will be fully serialising, so it's probably copy&paste from 32bit code where it would be necessary in principle. ~Andrew [1] https://www.righto.com/2023/01/inside-8086-processors-instruction.html#fn:pc In fact, anyone who hasn't should read the entire series on the 8086, https://www.righto.com/p/index.html