NetBSD Problem Report #59188

From www@netbsd.org  Mon Mar 17 11:01:13 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E1ED71A9239
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 17 Mar 2025 11:01:12 +0000 (UTC)
Message-Id: <20250317110111.E19AC1A923C@mollari.NetBSD.org>
Date: Mon, 17 Mar 2025 11:01:11 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: x86: trap 21/15h #CP pushes error code but handler assumes it doesn't
X-Send-Pr-Version: www-1.0

>Number:         59188
>Category:       port-amd64
>Synopsis:       x86: trap 21/15h #CP pushes error code but handler assumes it doesn't
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 17 11:05:00 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, ...
>Organization:
The NetControl Protection
>Environment:
>Description:
According to

Intel 64 and IA-32 Architecture Software Developer's Manual, Vol. 3: System Programming Guide, April 2022, Order Number: 325384-077US, Sec. 6.3.1 `External Interrupts', Table 6-1, pp. 6-2 through 6-3,

for interrupt vector 21/15h #CP `Control Protection Exception', the CPU pushes an error code on the stack.

However, i386_trap.S and amd64_trap.S use the ZTRAP macro which assumes there is no error code pushed on the stack and pushes zero as a dummy:

https://nxr.netbsd.org/xref/src/sys/arch/i386/i386/i386_trap.S?r=1.23#323
https://nxr.netbsd.org/xref/src/sys/arch/amd64/amd64/amd64_trap.S?r=1.55#481
>How-To-Repeat:
code and manual inspection
>Fix:
Yes, please!  Just use TRAP instead of ZTRAP for this interrupt vector.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.