From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.93 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796112499; b=CuC0HvhfGjLiXD0U5VSTVUBtTmn1C8z+s3Ujz+DrDAZ2iCJRUb17OGkiMVc3zBlym5mX BB8TytislMYGOzUU5kED4GHdH+8Cd4j43ue/gZPUj9+ensnwBtmnQKFhgcEcJSmpjQhBb 2I3hVhH7TeyuiORygBK7+n36LAtnZc6VEuGaWMaeaNT4qCy7HBHfDKOapx1SuYnUYrZ8J /ObFgkGpOqiRxVdeakw/1kr48chRRoxVA5DbxzDld0shzUjHJO/WRPRKxFoVbqxSXeF3h yZzCu2vKiSlgynCk7dr7QAVC2eplfnHhqrne6gBKzXn457BFtqvj6tNsWKK94Aj23yA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796112499; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=gPMCzbY0hIu1dWm17rqm/SfRqKLdpkkykwPeqsxdC4E=; b=ithBifnuqifYqc38axBSgF59scvdGCQM2Cv3KkPBNQI3uM1c8ANf1I6qpq8XaN3UZImz hnnByAkhVfKqCWGttZsBtvva2meaNDVCHOQ9rD1uLjVFnRdJ0S5d073nlrYYwzCcE9PyB RzYcXmmXWpWIBziS8QLw2E/P8LAa332wxAkWHw1f8fSXnsiCu5AAM5M+HYd8oYCVqrOol GDBDhv6JAQ+OKGg0Hw+HotusnBKHyKssnlQ20faPv755Y3WDEyBy9YimQ24KBrDlzMneF OIshkqsmB1EN2dvtjxzaRDiTvxqyMMIh2Lv5ELUxu9YjdoTZ72rxpAEcd9OGZMuiq0g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=OwdgKvXm; arc=none smtp.remote-ip=95.215.58.93 Received: from mta1.migadu.com (out-93.mta1.migadu.com [95.215.58.93]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E2A6606A325 for ; Tue, 1 Dec 2026 08:08:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5E2A6606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=OwdgKvXm X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=a9a6UwrNiATbVoeiPiwE3Gg0Enu8CZH+aj7a2kcysLE=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796112496; v=1; x=1796717296; b=OwdgKvXmVGNsrja7KzY2TJ+8ziqizwpN0HkNY6Z4FngO2zOR7HgiMGwgJhM2SaCgXW1mMzbU Xq3ENNcjdl9jtX7pg61/iD10HoAwjktoTZwZ7+79y9h5pzg8/nCvUO9W/zhPP7BbounY4tKUXmQ JzWs0OrFgiTOCeQyxM9BIxNQ= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 8d186b89f7793da5; Tue, 01 Dec 2026 08:08:16 +0000 X-Mizu-Trace-ID: 8d186b89f7793da5 X-Migadu-Flow: FLOW_OUT From: George Guo To: yangtiezhu@loongson.cn Cc: sashiko-reviews@lists.linux.dev, chenhuacai@kernel.org, hengqi.chen@gmail.com, loongarch@lists.linux.dev, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/5] LoongArch: BPF: Add support for exceptions Date: Tue, 1 Dec 2026 00:08:03 -0800 Message-ID: <20261201080803.282502-1-dongtai.guo@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On 2026/11/26 03:59, sashiko-bot@kernel.org wrote:=0D > Do build_prologue() and __build_epilogue() also need to save and restore= =0D > LOONGARCH_GPR_S7 and LOONGARCH_GPR_S8 when is_exception_prog is true?=0D >=0D > In the LoongArch C ABI, s0 through s8 are callee-saved registers. JITed = BPF=0D > programs normally leave s7 and s8 untouched, and any called C function sa= ves=0D > and restores them in its own frame. When bpf_throw() unwinds the stack,= =0D > however, bpf_throw() and its callees never run their epilogues; the excep= tion=0D > callback restores only the boundary frame and returns directly to the=0D > boundary program's caller, leaving s7 and s8 clobbered if any unwound C=0D > function used them.=0D =0D Yes, this is a real issue. The JIT does not save $s7 and $s8 because it=0D never uses them, but the C functions between the boundary program and=0D bpf_throw() may use them, and their epilogues never run. So the caller=0D of the boundary program can get $s7 and $s8 back clobbered.=0D =0D Will fix in v4: reserve two more slots below the $s6 slot for the=0D boundary and callback programs, save $s7 and $s8 there in the prologue=0D and restore them in the epilogue. The callback reuses the frame of the=0D boundary program, so its epilogue restores the values saved by the=0D boundary program.=0D =0D Thanks,=0D George=0D