From nobody Mon Feb 9 01:17:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673098899; cv=none; d=zohomail.com; s=zohoarc; b=RjWW8QOZzjuLqFnQ2paRT+rMWT1RPfB1utFYCooLrOb1t8KhdNCPBY8k5iIxe1YpkJ8rgBHzJBxKeJMs3uh36LgKW/r7BSFxV5WEietp/GtUaHCPzKyNeeMcMAsqXQq+/ulFl0ijvsh/Ov6i2xArxBwDYZKPRJVF/OxXTqmTols= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673098899; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lsotlKgI1bmgTWTvhY3ujDrNOOpUg7MBN58SNrn1JEU=; b=g5Qw15b8/oRlC/bF8QQAEECt2s3QzRFMBqO9oHvGVa1qpZ01nUlOR87ccE1JaHm5LlVAXk42AWBrvaYUsG0i6Lef5dhBQU9dMfjUq00GsqpWpjBbcUUFV1K6KxE63u3po0YvZqEfM/a/ZRt9VGmI/p7seHyq4IQ85PYyeiHsUwA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673098899294158.79453283029807; Sat, 7 Jan 2023 05:41:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pE9RW-0005FA-Fg; Sat, 07 Jan 2023 08:41:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pE9RU-0005EV-VB for qemu-devel@nongnu.org; Sat, 07 Jan 2023 08:41:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pE9RT-0002sY-2G for qemu-devel@nongnu.org; Sat, 07 Jan 2023 08:41:00 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-670--sNQNxa1NQO1afn2xLeY5g-1; Sat, 07 Jan 2023 08:40:53 -0500 Received: by mail-wm1-f69.google.com with SMTP id fm17-20020a05600c0c1100b003d96f0a7f2eso4270725wmb.6 for ; Sat, 07 Jan 2023 05:40:53 -0800 (PST) Received: from avogadro.local ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id j1-20020a05600c1c0100b003cfaae07f68sm10839439wms.17.2023.01.07.05.40.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Jan 2023 05:40:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673098857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lsotlKgI1bmgTWTvhY3ujDrNOOpUg7MBN58SNrn1JEU=; b=QVqxJQVzP0PK0DXPadvzsNA5DSRH1RTNq8DZx8s3X96EVvnrjs+mzea7gKD09yKHutMSsW j3GKsNMocGi2npishy3skwfzzdLv75NTABsu9gDu3kv/hi/myVOjPmK++8SlfZmHS4c6mG RR6YzX5yZL2aA+XwX8icJDyWIJInSrY= X-MC-Unique: -sNQNxa1NQO1afn2xLeY5g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lsotlKgI1bmgTWTvhY3ujDrNOOpUg7MBN58SNrn1JEU=; b=ciHEaUrK/nl2EjKrOkmkSdFP2+cQu+P8UP3JO1IxHmsEaQhCCrEk55/ipeDunc69D3 kHWmJNqBb3U3cdMlxlAznjn97x4x8f4aQVYRcu6sN75erW8iM0nv6uOETUMGuO+ZrrzE nAWsZ5J9JUQwvGFdh4tfRAabK9e11JfEsbQ1AEWi8OsxLxkvA+FP7XIzFw0Z3vJT791H X6thi1T1chDV6Tw7mQOuIieZQ1G0jxxCx0/KdgC+DD1/hkq/VQAnbdWZ85InMoKT/9Zl XXNHB7Fxvtlhs3uc51N6SwfaOoMnxse3np5m1kzFXhFFJmx/BuxS83/h9Cl7V4Oon8IS 0SPg== X-Gm-Message-State: AFqh2krwrukjSq5QBS+lT8efi+L+5QrnK2yAyTqV8QcJwmR0/GIsbRNH AiklxlXdtohUW7cgfMX8xo2qYICQRLAFPdjf9RLJC9znc/rWdzBSCnKivDyQCsRcihripPsjLJ5 hE/enobcGThXwKN2yEzMbJsPdI6MfWMUZXY6nVSmCvdVt4aBo1QREsD51CLYH0my1m+I= X-Received: by 2002:a1c:4c12:0:b0:3c6:e63e:89a6 with SMTP id z18-20020a1c4c12000000b003c6e63e89a6mr41934859wmf.2.1673098852297; Sat, 07 Jan 2023 05:40:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXugqhok9N4tHJbw0pEcZz7iBR+kdFNXQjCoo5lx61UcWJ3GrNaKzY3GLa1Jd2jxG9IyxOlK3A== X-Received: by 2002:a1c:4c12:0:b0:3c6:e63e:89a6 with SMTP id z18-20020a1c4c12000000b003c6e63e89a6mr41934848wmf.2.1673098851927; Sat, 07 Jan 2023 05:40:51 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH] target/i386: fix error code for exceptions caused by IDT accesses Date: Sat, 7 Jan 2023 14:40:44 +0100 Message-Id: <20230107134048.110885-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673098901115100003 Content-Type: text/plain; charset="utf-8" Exceptions caused by IDT accesses have the interrupt number in bits 3:10 of the error code. When in long mode an IDT descriptor is 16 bytes in size, and due to a copy-and-paste mistake the multiplication by 8 (shift by 3) was changed to a multiplication by 16 even in the computation of the error code. Fix this. Reported-by: Michael Petch Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1382#note_1220619456 Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 539189b4d184..03b58e94a2d4 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -882,7 +882,7 @@ static void do_interrupt64(CPUX86State *env, int intno,= int is_int, =20 dt =3D &env->idt; if (intno * 16 + 15 > dt->limit) { - raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2); + raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2); } ptr =3D dt->base + intno * 16; e1 =3D cpu_ldl_kernel(env, ptr); @@ -895,18 +895,18 @@ static void do_interrupt64(CPUX86State *env, int intn= o, int is_int, case 15: /* 386 trap gate */ break; default: - raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2); + raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2); break; } dpl =3D (e2 >> DESC_DPL_SHIFT) & 3; cpl =3D env->hflags & HF_CPL_MASK; /* check privilege if software int */ if (is_int && dpl < cpl) { - raise_exception_err(env, EXCP0D_GPF, intno * 16 + 2); + raise_exception_err(env, EXCP0D_GPF, intno * 8 + 2); } /* check valid bit */ if (!(e2 & DESC_P_MASK)) { - raise_exception_err(env, EXCP0B_NOSEG, intno * 16 + 2); + raise_exception_err(env, EXCP0B_NOSEG, intno * 8 + 2); } selector =3D e1 >> 16; offset =3D ((target_ulong)e3 << 32) | (e2 & 0xffff0000) | (e1 & 0x0000= ffff); --=20 2.38.1