From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 84BD33EBF09 for ; Sat, 24 Jan 2026 23:07:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769296066; cv=none; b=og9akRDl9qc4yVRvYFj1VbYUTu9dTDd147kl+b8Tb4vaPyxO6IuNZQFoMmGcBihL8pHgZHS3/jQoY1fq04LHE+nItFKY+hiJssGMlokeRj5oS8UZomvr1d7C2RWOnWSML9CA5qT+xmxygWGLfvJRyqP7nxHW7U9U6RFC3ax8RqA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769296066; c=relaxed/simple; bh=XdRclpQNCqX0dBKBzXTJ7tNS318KuBUco8Gn5/CC7+o=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h8cezfytGfXtH49wSX6cJ4y7Wf6HxuyoPUwwiBXMsuOsld40G6zZOihnpCya6oARd9U7NDQTW5m5StvHZ7MobCz34D23Hlm/EsuhMDfNPC0luoVWQjGhpXuPZR67GpKWtFRo0oKVhZryEKx48T7sgDh32rK9+j/J4q4kgYDJIyA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T0czgzaI; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T0czgzaI" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4801d1daf53so37205015e9.2 for ; Sat, 24 Jan 2026 15:07:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769296064; x=1769900864; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=PEL8IrKUsSqQwu2k31LQ413w8P8f+OHWaTO4r/AtvUA=; b=T0czgzaITA9Cbyr4IuQ+pHfk74qlQS/lmxvDEbGi39cHpjmuxPDYdsUSJk6ohaqUxt YrcPhiQVrOTi6ib8RS3gOQHntmRcvT1IgJ8KauGyNvZgAL0y3xEQspTJXc/6YhcUylMM PZgSaCQPcfkAVdGAHQ1ThhsVzwu+XjRpTrWRmLys0in6xVlq/Vek/I6IEOPEvP1CXJt/ EbQxFSFybjt0PrF1WHWsIOTZcAwg63IBbTxOF+cXrbzpW8yst/w7pHOF0hCK0JL+mbwq gzd2M8rmMMqct4UBLLUnhlwwaw8Lyg7Q0MeuxgA0ivUqZZOvT1vxWfeGiCJr0+JLHRs6 R1aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769296064; x=1769900864; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PEL8IrKUsSqQwu2k31LQ413w8P8f+OHWaTO4r/AtvUA=; b=tQxVm8DO9un1VbBJCxuYm5DuFrjKa1eAyft2Dkr0PjtvsE+y0nSYgRNkQbFLs4SkLB 9OHrvqtW5H6sr8bSomTTISERlbqCx0fYSypg37ENKY/SJjShrckdw5cY6HgFVlLXgqQ/ ow3QcRWKI9O53pssIt6pK3v0QbeDSvIEYwHu32StX8MA9pd4GFjzvd8z+XuzkBomlQKY vlNP3vSstmvkCL6EA1GMSKTax8JUmxE8u+2nlJw5NX+MXD7n3KP7DrPE7YH5r++30BEs 3LHiEDEUW0zkwhVNvFcsC6TZuTgVONF+MebE35SVJuVXNiTXTMby0CWCDVYUcm5alfiX uahg== X-Forwarded-Encrypted: i=1; AJvYcCXfo7WhAiKtT4jJbSsoCy8R0hGMRSH4Ytzf9iozI9cJRcPeik8Q8FQPkNMNSSk/Mi7uAPf1uii3Ny95cDE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx0/Q4l+5JNipov9e5wXv13PVjd/PAI/JBrWrENHbAWQ6WMZkeF btAcpuyAoCKvplyDEkRavt8Mo71bW6rwEFMeu0DiG2HvTL18nfUTmOrK X-Gm-Gg: AZuq6aJIdPu6cFMuEF1hG3ZoUiwAWwd1cvThz6glrWKb+sTpbRC6GGo2JCZ7Wj8okp1 zt8FTBz91NQDR+VB33q9YApK7W8swGYHshkLzyTmP7/xykMPaRgGS+fx6/uWxr8+cW0maBCjSj/ wwLQJteQY/sNlOxo29a2OLHVQl0uYoJaD3q+NCP6l4wZ402c6RIGk/3SEkM5bOoPA3Qr6pzvQJK FnpQIOtiRwjujQMKPVJjTK106lk10aMywcrnF7eoAXSIX6ayEaW+Afp2T2kZRojgNR2NisD5pu0 e0gQbR7sAWcHwidtqzeaxdcJNpgTNW5UOxBFE/wr9r81eIg3TEw7NRTCSoqfm6WWpSSDQzkM9qs kpPxqYuZ30Mk1WDWqmFv0mR2X/JDmBYV6vB5k+fuRz7dZj4ToanhDKycV3pQ4qcFJZx8is9nKHE VHe2u+DSTZuhO7Aap1tuXOTHkkgqmm/Z9o1+CWjXF2Bk3zpobNXPaL X-Received: by 2002:a05:600c:4f86:b0:47b:d949:9ba9 with SMTP id 5b1f17b1804b1-4805ce40c8cmr1981265e9.13.1769296063617; Sat, 24 Jan 2026 15:07:43 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435b1e71503sm19168491f8f.25.2026.01.24.15.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jan 2026 15:07:43 -0800 (PST) Date: Sat, 24 Jan 2026 23:07:41 +0000 From: David Laight To: "H. Peter Anvin" Cc: "Maciej W. Rozycki" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Uros Bizjak , Petr Mladek , Andrew Morton , Kees Cook , "Peter Zijlstra (Intel)" , Nathan Chancellor , Kiryl Shutsemau , Rick Edgecombe , linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, x86@kernel.org Subject: Re: [PATCH v1 12/14] x86/boot: tweak a20.c for better code generation Message-ID: <20260124230741.2b94b14c@pumpkin> In-Reply-To: <981124b5-040e-400b-9912-15a65fdfdfdd@zytor.com> References: <20260119192923.651588-1-hpa@zytor.com> <20260120195407.1163051-1-hpa@zytor.com> <20260120195407.1163051-13-hpa@zytor.com> <20260121114911.6adc2838@pumpkin> <981124b5-040e-400b-9912-15a65fdfdfdd@zytor.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 23 Jan 2026 20:24:55 -0800 "H. Peter Anvin" wrote: > On 2026-01-23 19:00, Maciej W. Rozycki wrote: > > On Wed, 21 Jan 2026, David Laight wrote: > > > >> No loops needed. > > > > A loop is needed because there can be a considerable delay from issuing > > the I/O request to flip the A20 gate till the circuitry responding. This > > is particularly true with the command issued to the 8042 device, which is > > a microcontroller running its own firmware that needs it time to process > > an incoming request to drive one of the microcontroller's GPIOs. There > > was a reason for port 0x92 circuitry later added to the PC architecture > > with the IBM PS/2 being called the "fast A20 gate". > > > > Indeed. I thought I had responded to this already but I hadn't, apparently. > > Note that the "long" delay is 2^21 loops! That number wasn't taken out of the > air, either; we found machines that actually needed that many iterations. Ok, so you need a loop because it might take ages for the value read from 0x1000200 to change. But there is no need to keep changing the value. The comments in the code don't really stress that. > In the case where A20 is enabled already, the loop terminates on either the > first or second iteration (the second iteration is when the value at 0x1000200 > is exactly 1 higher than the value at 0x200. > > Modern machines (Nehalem+) already have A20 enabled, and most machines of the > i686+ generation implement int 0x15 function 0x2401. I know some of the history. And just read some more of the gory details... A20 being disabled is there to make a 286 compatible with the older 8086 PCs and any software that relied on address wrapping (rather than using it to get an extra ~64kB in real mode). That would be for dos and win 3.11... The only 8088 and 286 cpu I used were on IO cards. > > -hpa >