From nobody Sun Nov 24 20:03:58 2024 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=1720955500; cv=none; d=zohomail.com; s=zohoarc; b=hvIYRfCtPpZ3Yc03JGDroBhsQDmOAnCsKGh3UyaC0gOHI2BiAxTpcGe3JkARz35WAQ7y3fNmXioFGG7tuHgrEjTg6m7xuXEG5WCKWuX8FaXnxNGLCG53oy6B6119kE9BD+NDv4HCd8Elx85X28fSytc76twQywcUiBWFYegqvzY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720955500; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h1MZ+bkr2S4w1UHUKLxqB+jeJD0WXRw8G5s2UmrXHqY=; b=BepEo6LCpriqqjn+YYRCghZaGB9tekJymmAXzIgwPnQKWeixaUP67WYC0D2VhvEbzqUIfuOrDnZA2UfAuNJdKsk8XpWEJqxNzq8W3U7U65xd7Hwmb5rUeFKM8673WMm2WEYKm2OmcztUJrRRsMtgvfc6t68hCOceoKesqHp90PM= 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 172095550025090.86324902830484; Sun, 14 Jul 2024 04:11:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSx8S-0005dk-4q; Sun, 14 Jul 2024 07:11:20 -0400 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 1sSx8P-0005Rl-15 for qemu-devel@nongnu.org; Sun, 14 Jul 2024 07:11:17 -0400 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 1sSx8N-00028l-Jw for qemu-devel@nongnu.org; Sun, 14 Jul 2024 07:11:16 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-206-2Am5PLzNOCmKVLzTFKRlFQ-1; Sun, 14 Jul 2024 07:11:12 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3678e549a1eso1778246f8f.0 for ; Sun, 14 Jul 2024 04:11:12 -0700 (PDT) Received: from avogadro.local ([151.95.101.29]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dafb991sm3629295f8f.79.2024.07.14.04.11.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jul 2024 04:11:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720955475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h1MZ+bkr2S4w1UHUKLxqB+jeJD0WXRw8G5s2UmrXHqY=; b=bnFXzFFgYPNQAESV8YVyUKjHaGNUPhagIDTjFUikcV0wPp1KqhUh8727ubMgPgI2bYQVX+ 9hb2zmfRMOiwIec4hXsXwJ9yubqFI1RsVcGDFPyVdmLftCJfNc12qGWiaa6WZNeLkLCbCY B3FAQuHtUbUprBCakbtGpOusdQZELcU= X-MC-Unique: 2Am5PLzNOCmKVLzTFKRlFQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720955470; x=1721560270; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h1MZ+bkr2S4w1UHUKLxqB+jeJD0WXRw8G5s2UmrXHqY=; b=S0NXfe2lafNDIrxd64X0NecYOaOxIzcDsjq2E0c/Iyn629FTNj1eolAHWrB4uIJOW0 vsNwA/atRY3QJ3I8zYDFc9PphmYLC3p9iJ4fh7KhKj9d8aNK1jr7LXw1HRRq4Yc/MfSd BBxrDo1BvjquGiZBaMb+dt0NqRnlb8+86J9rHbmW5pvT/57Opp/Q/srdaCVqXRRhUHda vbeHmNDhtEh2MZ0NfyDqribvObYzc10mCr7twEjMn3SHNOru86GcGl/WilgwSzWL6iah xhmZHYcxmAGHpE1QAsfbs0aLmw9PMg11hTUmneqqsIrcswFyAB8Zqs7p+/Vk2XmOrZNu XDCg== X-Gm-Message-State: AOJu0Yy4kspljz1cKTQTxsW/lumaC4Ee7G87k9lL9FAt2uczZ5nA0mzS 1L/8Yq6T5ayClPWuksc7kmj4Suu3C8JlOEKl/L2T7FMLH0YixlO44/hY/HD687ik9WJ5P6nG3pi 60ngwFo/8myze6Bu+BKhvjU8cBRmBwEUoajpevnfNb3uPxh0NjCOe0b9Lz5IOFVBgevdejWbqZ+ 8S4WuFTe5rHWXjvWqx+DkVGVysEsBznMmOMmIZ X-Received: by 2002:a5d:61cb:0:b0:368:4c5:1697 with SMTP id ffacd0b85a97d-36804fec68amr4152891f8f.36.1720955470192; Sun, 14 Jul 2024 04:11:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFWfJpnWBr9IiXDeAClNnjM7WB+R+NZ6Au0q0kiBiLn8Sa9ntWWTzUVyiCuJWwDccZCjKS7LA== X-Received: by 2002:a5d:61cb:0:b0:368:4c5:1697 with SMTP id ffacd0b85a97d-36804fec68amr4152884f8f.36.1720955469892; Sun, 14 Jul 2024 04:11:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Richard Henderson Subject: [PULL 09/13] target/i386/tcg: check for correct busy state before switching to a new task Date: Sun, 14 Jul 2024 13:10:39 +0200 Message-ID: <20240714111043.14132-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240714111043.14132-1-pbonzini@redhat.com> References: <20240714111043.14132-1-pbonzini@redhat.com> 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1720955502126116600 Content-Type: text/plain; charset="utf-8" This step is listed in the Intel manual: "Checks that the new task is avail= able (call, jump, exception, or interrupt) or busy (IRET return)". The AMD manual lists the same operation under the "Preventing recursion" paragraph of "12.3.4 Nesting Tasks", though it is not clear if the processor checks the busy bit in the IRET case. Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- target/i386/tcg/seg_helper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 809ee3d9833..0242f9d8b58 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -369,6 +369,11 @@ static int switch_tss_ra(CPUX86State *env, int tss_sel= ector, old_tss_limit_max =3D 43; } =20 + /* new TSS must be busy iff the source is an IRET instruction */ + if (!!(e2 & DESC_TSS_BUSY_MASK) !=3D (source =3D=3D SWITCH_TSS_IRET)) { + raise_exception_err_ra(env, EXCP0A_TSS, tss_selector & 0xfffc, ret= addr); + } + /* read all the registers from the new TSS */ if (type & 8) { /* 32 bit */ --=20 2.45.2