Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3350022rwo; Fri, 4 Aug 2023 03:39:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0XQ5fEDRLFBNWh3t+YQPZQ1UiDgjxZraQok6ybkisEDoAncBBbMVsZs9i0jn9MT8fBRk+ X-Received: by 2002:a17:907:774f:b0:99b:bd1e:b00 with SMTP id kx15-20020a170907774f00b0099bbd1e0b00mr1129719ejc.25.1691145544923; Fri, 04 Aug 2023 03:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691145544; cv=none; d=google.com; s=arc-20160816; b=ujT2wVlXz4romp6xV6R2nqrpidWo8A4mIY17/Uy3Kvm+YooAkHvk/dwA5ZGBOMFqO8 CMy7tGFiU2SNyfml5Lr8HdfYte+sg3wOdp7LSQMlhRuaVcYN03yFWPJ2bln0u0eCYunn tyR5XbGvVuaKybL53o4zq5EERxuOj9OPiCN2loqKE1VajHG1iIFd3Wvq4M2TE1R8kCoU WOFJyzByTmnmnNoT+u5oAxs2wtULMU7YSXxou8Qqkr8prmEjWSlykCTnEJ91nE8EVhru 5g5mLyom+SJms8Ps2VMMpO77tRkPeyApUl7kRedsBg9PocU4+KP4khHSNCmUTdm0ZiFB kvaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GYK9+OGfxviHr18NI+B7bkONaqcCERrPUSZDWZMRPEQ=; fh=4RmndOB0vAf3kJM428ThdLxmMrIrpifhKRYdaaoWQSw=; b=nMb+hh6RwgwHBjh3VxVpfMHf9Lf6ya/DO5XX2BNja9HNmpt+wdYHr9QoWH6QOANXvf nC3OB1iz0brpFFIPcYCIwL0auNpRzy89AVXdQeyNJcHvuZMJ4170WCXECK7nf+XsUspJ Uju+5Ka3q/2whKvFAA19sv2kLEMW4oc5LVFGtGs+UIJnZX/y8L8YDTubiZPUNrA0VKy4 0FVUY25qD99sTx/s9sBnG+M0RCgY9im+2X5iX1EvMcCf9NE5kv66TNYKaHOE42yiSgni gxPTG91SOMDfeMXABBFv8aRj54lONY0wLfXKWm05w1yTMgBNUwNEotEpYrvnm+hS+RbT TxqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Si4qEE3c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k5-20020a1709067ac500b0098dd7b3684csi1284159ejo.994.2023.08.04.03.38.37; Fri, 04 Aug 2023 03:39:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Si4qEE3c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231435AbjHDKOq (ORCPT + 99 others); Fri, 4 Aug 2023 06:14:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231407AbjHDKOB (ORCPT ); Fri, 4 Aug 2023 06:14:01 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0727249D7 for ; Fri, 4 Aug 2023 03:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=GYK9+OGfxviHr18NI+B7bkONaqcCERrPUSZDWZMRPEQ=; b=Si4qEE3c+HJrS2LkWUpXkEpwIY z2QG84d95tw+UddPI6rUzadRriq2PDZYJ6XXgw1x4zVAysI26DpGR+v731iLeXUZpRG2lgIbPY72I 85Z6xFBogTIWFnZfNZ3S5QtL+ki4RcsOQiafmnH+Ad4fikMc2BFW263jmaF+Yq1RI6wmtI2QFGM9e ynZc/AAqQWPF0jP6VORFQ68/nqLS5sz5Lw9voBgJBLLNR9+ghPabvhaxhVI/lrVi2pG/Art4rrfjP Ipm/2XkF12gk117ch8cTn0cq83XETEzdbxKMmrQET7kTOkjlN6SKIYhgKMGA8v/MhBhxLtLPW2cf8 KqI33mSw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qRroA-009Hn5-6s; Fri, 04 Aug 2023 10:13:22 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 400A730020C; Fri, 4 Aug 2023 12:13:21 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 1F03F2107C447; Fri, 4 Aug 2023 12:13:21 +0200 (CEST) Date: Fri, 4 Aug 2023 12:13:21 +0200 From: Peter Zijlstra To: Xin Li Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky Subject: Re: [RFC PATCH 1/1] x86/traps: Get rid of exception handlers' second argument error code Message-ID: <20230804101321.GH214207@hirez.programming.kicks-ass.net> References: <20230804075734.8372-1-xin3.li@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230804075734.8372-1-xin3.li@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 04, 2023 at 12:57:34AM -0700, Xin Li wrote: > The IDT event delivery of X86_TRAP_DF, X86_TRAP_TS, X86_TRAP_NP, > X86_TRAP_SS, X86_TRAP_GP, X86_TRAP_AC and X86_TRAP_CP pushes an error > code into the orig_ax member of the pt_regs structure, and the error > code is passed as the second argument of their C-handlers, although > the pt_regs structure is already passed as the first argument. > > The asm entry code of such faults does the following > > movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/ > movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */ > > to set the orig_ax member to -1 just before calling the C-handler. > > In addition, the IRQ entry code uses the second error code argument > as its IRQ vector, as the IRQ asm entry code pushes its IRQ vector > into the orig_ax member. > > The commit d99015b1abbad ("x86: move entry_64.S register saving out of > the macros") introduced the changes to set orig_ax to -1, but I can't > see why it's required. Our tests on x86_64 and x86_32 seem fine if > orig_ax is left unchanged instead of set to -1. That means that SYSCALL_NUM(regs) get to be garbage; or something like that.