From patchwork Mon Aug 19 07:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 820268 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c8:0:b0:367:895a:4699 with SMTP id m8csp1320931wrb; Mon, 19 Aug 2024 00:42:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXLZAO0EuV2XK5L3lilGKxfaWM98YjMg5vCE70eEO048i9uvXSGoIEZ0wmUy8zBRN8nheEIoJvDTWbgRGIUvPQF X-Google-Smtp-Source: AGHT+IGE22O4mu+I9gl39ZUBBBeXqPDhfw/diI//+v6DLkKr7nGM9MRJzM6XtqGgAaa5Nd/2kHJY X-Received: by 2002:a05:622a:17ca:b0:446:5c35:d9d6 with SMTP id d75a77b69052e-454b68254eemr67183071cf.23.1724053330813; Mon, 19 Aug 2024 00:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724053330; cv=none; d=google.com; s=arc-20160816; b=mhRT9/+47/UQ3LTbAa240Dfgs7qR13DgZ8VGD4cDfWi1ihz9QLSFlLeEOeqUcqIvcj BWNsFrLn7CpvVl38NpYSKlo66XNUdmv4bYznNEX+nuG0zVGmDvUHmLgu/RsyMqTna/Qv oY2mVpd+Lk9M/v0p4M7z7Im8zorY/VKsVh+2qtvm5Czd7f0Kz6BDVvaupMi8LuxHmi0A Uzo9hIjxyD5DdqBBTZAQJU3OdxG0yokXmtYgpJOyzFvJtLaS+nfWZePcmfE9bPtyNEIV JgNPmq2TsOYC0cP5dBnBKT0//xFEt+TZC8UD+u0ByuROGDfZ+Jj7m7gM6L9uNVXRc8aZ QOqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=8HC5xX2RS5vhAXN7obJucV/pCAXzmZwlnRs+P8vxQ10=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=No8qimSrSEQ7qsIzKXGDCMmvofNM4NKyuH6YriT9p3NnTxt0qFx1bDhgmjToVVpHPD jtRN63xzKGmHEX/72QAyskuSE7bXiLQMrdjiIdLBuo0YsUeWNkwfBVHyRp3wutVFnoyQ PhR1iLPQI0T6DU46GRNPnOvthq73IlAX4iQ8lPrqHT82NRTpqbDcIXppU1A3DKB7JqAD Dv26TrSEHgpOKr0Kpa/2lp0t1gPzspjgCyiSvNUDdAoFq3kqmzj2Smz9Ct2Gawa1Y45K Vo6Z7kPlGQXFgv5LqcBp1AMIFvx5V3bTSJ5vQedUHD4iY9aksv/U5ubBDrFuA8/CXRkS FSAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrtsIr7R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45369fe648bsi99227441cf.89.2024.08.19.00.42.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2024 00:42:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrtsIr7R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sfx0l-0003Os-8A; Mon, 19 Aug 2024 03:41:07 -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 1sfx0j-0003Ng-Of for qemu-devel@nongnu.org; Mon, 19 Aug 2024 03:41:05 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sfx0e-0004LL-L9 for qemu-devel@nongnu.org; Mon, 19 Aug 2024 03:41:05 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-20219a0fe4dso13609995ad.2 for ; Mon, 19 Aug 2024 00:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724053259; x=1724658059; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=8HC5xX2RS5vhAXN7obJucV/pCAXzmZwlnRs+P8vxQ10=; b=LrtsIr7RUbG4b+Oovy3eZjDH9mnR72f4ozkBvUGq4mF9xdhyZNCB+FBYPwHq20sHSU s0UYOlWtAOZSkp4A7r10UzHNzYk7eD7XGY1u6TwdV6QToFaUZcxAVeNNfcTIeeO7Vfkl WNEEghRpNYgs2i5mfr5IRefJeINiVSUE7CWq4AIDpHJVgGYTicu469+bMQBlqvLBn0WR gGx0F56o/fG/MOKIpnvp6EORjH1uLuWe8NL7Py/BAFhiAFwwOE8tW+o4l/QAT/brQjnO fqrWRkCkn0FXPdya0SzpIXU6xutnwKVxKcE2wPl7TYLiPqG56V8CkoRqGxdr903E2RAo RUMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724053259; x=1724658059; 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=8HC5xX2RS5vhAXN7obJucV/pCAXzmZwlnRs+P8vxQ10=; b=SX2rzjSm1znVgyjwxx7AQljjC7NaIXVFSyj666H4yyPe4tzdZO+YeU4K9iNZyO7K+e fFkrDrt5jIaMP0B6KMKVKkKrcYybDCqOsS5mBGLvJMBcHyFvbeTFDSUgA6qxc8r/u4hM 6j/DcVjDW30dQTi75VkSvgKLg8XnkouKpRzXZ87KFTmG5srCD5g5YUivs3ToHDAO7EfX Cy7jDSukoHFz8d6O1xIcV1KNlFL8A3/B8hfYr79pGh+EwK7P35BlE/jOwJUg0+fkwysh rsEnfiVlxbdMeoGONQH8ZKFmDXGLsxqBcheHquxDiGJwoiLSe9XhKz4Z8illIynAWFie SY/g== X-Gm-Message-State: AOJu0YwkREuKNQCUqxq/qZ4JvusJvIKzMKbjBZlsgnBM+mKfkZXdOopg bOVBKRYblRbW/wZYYhTSYJQVdTzcx9zyag7BSzcY0QrBQh/LBMqqtyIxe+bJFCq2h04Ps9RoHYH Sblo= X-Received: by 2002:a17:902:ea10:b0:1fd:a7a7:20b7 with SMTP id d9443c01a7336-202195eb41fmr81675895ad.30.1724053258442; Mon, 19 Aug 2024 00:40:58 -0700 (PDT) Received: from stoup.. ([203.30.4.109]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201f030202dsm58399945ad.34.2024.08.19.00.40.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 00:40:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH for-9.1] target/i386: Fix tss access size in switch_tss_ra Date: Mon, 19 Aug 2024 17:40:52 +1000 Message-ID: <20240819074052.207783-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The two limit_max variables represent size - 1, just like the encoding in the GDT, thus the 'old' access was off by one. Access the minimal size of the new tss: the complete tss contains the iopb, which may be a larger block than the access api expects, and irrelevant because the iopb is not accessed during the switch itself. Fixes: 8b131065080a ("target/i386/tcg: use X86Access for TSS access") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2511 Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Pierrick Bouvier --- target/i386/tcg/seg_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index bab552cd53..3b8fd827e1 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -378,7 +378,7 @@ static int switch_tss_ra(CPUX86State *env, int tss_selector, /* X86Access avoids memory exceptions during the task switch */ mmu_index = cpu_mmu_index_kernel(env); - access_prepare_mmu(&old, env, env->tr.base, old_tss_limit_max, + access_prepare_mmu(&old, env, env->tr.base, old_tss_limit_max + 1, MMU_DATA_STORE, mmu_index, retaddr); if (source == SWITCH_TSS_CALL) { @@ -386,7 +386,8 @@ static int switch_tss_ra(CPUX86State *env, int tss_selector, probe_access(env, tss_base, 2, MMU_DATA_STORE, mmu_index, retaddr); } - access_prepare_mmu(&new, env, tss_base, tss_limit, + /* While true tss_limit may be larger, we don't access the iopb here. */ + access_prepare_mmu(&new, env, tss_base, tss_limit_max + 1, MMU_DATA_LOAD, mmu_index, retaddr); /* save the current state in the old TSS */