From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 C561931E838 for ; Sat, 25 Jul 2026 10:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784975691; cv=none; b=NYIMIfOua3HPogVvwysVFW1WUj7re77RcFIjuKq47KiTyJ5rHe86gyq2dYctJAklCn/Y3AG4/1UQXBCRUl8lrPnYFud0phB01fdB4AJo09MMd/CXgjJJdOYvk5oEjhoZ41Rjv/L2gE/THhp6uEM9lKAR6cvTDAknOhrv+5QHj3Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784975691; c=relaxed/simple; bh=WBEG28DeTx0KKq+YSDYAKSzoeCsNGHqAd25AApm/Ai4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aLiYSCvY4BjtXnKM7i7OLeocSeQX3tRARG/gxIHt9KUwIxM9ZXHjWNKN8s7GO52jMyiNU1hxFfuG1LQbjK57UP5Xh2mgUCyZG32MWpVTjdOKBClOMi9U3Y48UReZ3h/3tJILidHMSmaBKgJHynlXAp+JRbz40CifPqX+D/wIM78= 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=UKay02Vp; arc=none smtp.client-ip=209.85.128.51 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="UKay02Vp" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-493b966dd74so7734015e9.3 for ; Sat, 25 Jul 2026 03:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784975688; x=1785580488; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=lPQ1yd3wvQrSfjKjwB6za0d4edq1Z4RYR+4kmUZXqy8=; b=UKay02VpXSds7vqUhKTcSkgwZWOJpXFna3bilOe0vRl+J7zBm6phMw2L+DDpHr+8MU rmFupUskF/ZycvoanfrYTo/VgC4fI5EEWcN6/zDCMmO26B0UnVnn8Gjmb7WK0ovdnMjD AwOviAQc7vS44py5hfuvp433bFOk8A586JWwMJzwWScklRhq0oJ9oyc8e4dduuBpiPGv fMxMthPI1Xjrr71557A4EGtwK5WUY9xBuWxP4213T7Mh4al6YoPcEBxvq9hX9BNFJsqb jGuiyyxiG6S5SqePLc1fZerSX7baQaljaKJDuISB9xFX6y8+k+RsXoMysf+dFyPqFsWo J3oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784975688; x=1785580488; h=content-transfer-encoding:content-type: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 :content-type; bh=lPQ1yd3wvQrSfjKjwB6za0d4edq1Z4RYR+4kmUZXqy8=; b=cHhfUT7uYK51zW4UO/U+jLMDC8nMUcieUaypAOoxZ19sCa2aWFsFHH95oIJIHPCsPw Hu7tCyP2aOvr3N3mstzun76kS/lu1XVC1ktwaX3cMRxn0yZxwUQXrgWgpfwhKQSWwU5p JAcAR+qOfN5NNGRSKFT6upcZS7koLxQ2u9zVvGDt8umq+dH56Lh79VmGZPRw1rZ0vLZp q0SMmkzIXR4oSWf00QuHqNjWJt6GigclykC49DnSKFLYLpkcqCUStN4MGw3d7q/chS/m dZnFDdfJtOlV5y0ZxemopM9DMqlNNT8VEyLF5dCtJnqttMgMppPann+IMMsYZYJRRLwu K9WA== X-Forwarded-Encrypted: i=1; AHgh+RpIML5Efb1isL4rI+S/Dv9dYmiSaIP3u9x7EJAcauqXhHMPZvt525vJIShBy/U2/XjTB9U5ejcSaJ2WDp8=@vger.kernel.org X-Gm-Message-State: AOJu0YxZ6XjbWx3hUEXogXVfg18kAbi8Yv7SC4Q/u9PlATjrcneGYEk4 wYjkK5DqnZTbu4n2v5UpuinFqri7OhicVJkcJS93Zl0QwVKgcg0K6CY5 X-Gm-Gg: AR+sD13VNC3bWnFmWtnAk/0c5Of8gPKOXeMSaR7qRkLvviiQ6uyC7DHe7dd4QsDdjiB oPlGdTGlh5bdd1flqR4K4nNwu83TlxfMBZrBtRhpyg6Pi5KGgh5VUFyqLk+RxpbeGBFoalCG71o BlSfDzkLBsrcTiRl5UYsp1yo8IUKmohpGrMb4Znspb2A/Az6EA8O9P2VvBc4ECRSU3DMxItfNlq OYafk8xDPeSMTIQyiWrupmISSMb0K9p/X3XZ64FK6uxTp9zMc6WMG3h3QT4mA027RFeLushUhTf zd312FOgPvXHHuuvFiHwiFk49xCBoUW1VkDtp36Rhc6lqdMgV7r9Kfe8s37b2VfCvigpug7o+Wu t0c16YHlHUusxTE4Si9Ux9p8s1+EcEvKWmXQyY6Z2IB6VbFtHaE04nd0DEXoWfvH0C9XfzJdUPz gvlhjjrEn4C/hltcwgCewhCnmiicf9jbtw9IvAp0TkJ5rRmDE2WA== X-Received: by 2002:a05:600c:3509:b0:493:b87c:c87d with SMTP id 5b1f17b1804b1-496b56f3607mr21539045e9.11.1784975687659; Sat, 25 Jul 2026 03:34:47 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-496b4f302f8sm53865865e9.12.2026.07.25.03.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jul 2026 03:34:46 -0700 (PDT) Date: Sat, 25 Jul 2026 11:34:45 +0100 From: David Laight To: Brian Gerst Cc: "H. Peter Anvin" , Borislav Petkov , Mauricio Faria de Oliveira , Thomas Gleixner , Ingo Molnar , Dave Hansen , x86@kernel.org, Juergen Gross , Alexey Dobriyan , Boris Ostrovsky , kernel-dev@igalia.com, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Subject: Re: [PATCH v7 2/5] x86/asm: add volatile, clobbers and zero-length check in inline memcmp Message-ID: <20260725113445.14ccf42f@pumpkin> In-Reply-To: References: <20260721-pvh-kasan-inline-v7-0-38979a50cef0@igalia.com> <20260721-pvh-kasan-inline-v7-2-38979a50cef0@igalia.com> <20260722170334.GCamD35gwrCng30WH1@fat_crate.local> <0F3A1121-208F-4F71-8C88-BEAE7CB50E75@zytor.com> <2f22094d-b8c5-46ec-92b9-dd6752a8dc2e@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 Thu, 23 Jul 2026 20:49:13 -0400 Brian Gerst wrote: ... > I had originally thought that the test for RCX==0 was also at the end > of the loop, after the decrement. But a closer look at the > pseudo-code in the SDM does show that the test is at the start of the > loop. Starting with RCX==0 does indeed skip the comparison and does > not touch ZF. Your suggestion is good, but should have a comment > explaining why it's there to someone reading the code in the future. I have a feeling that was a change between the 8086 and 80286. I don't have an 8086 book (any more) but I'm sure I remember fixing bugs where %cx of zero caused 65536 iterations. (Fun to find because the vector table is 'first in the line to be overwritten.) David