From patchwork Thu Mar 14 23:26:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 1912308 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Og89S3gk; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20230601 header.b=FKr/UEJz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TwlYv3yyfz23rx for ; Fri, 15 Mar 2024 11:32:01 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kiz16i5U7URkLVGpKzpn8Qyj53ySYf3vsmUBS72UM0Q=; b=Og89S3gkpBKij8 d+E8EDY8G+6PHkBL/kIwOFxIRVz9eeLy/AGOMohy2yhu7CBoYA0NH2zGoTcCrhOikHsy/BJMNZV+P QlAsdCRAIYAoIyYaPhQmCUdAd5cwWyhks/MW+0WuBZq26ajkaLuAcykeN7bBp8mweq+DWD+NCTELK g5LjH+OQmOEym4EgNE+JUwhnLxkQSeYsY+lXyjo3cZf5ujYhl4OC13pR2XSYgIIULL0C6ZyQBuvod +oldl2rewwOZomr0u5LDC9/C7D8N60JUy5Na5olWaLnlymBBaIIa5T5MGJ/M/rewIujE8IylKzbQu CWlgBDxvvfmCTBvkDmvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkvUN-0000000GAky-30Dp; Fri, 15 Mar 2024 00:31:59 +0000 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkuTL-0000000FzwU-1w4z for kvm-riscv@lists.infradead.org; Thu, 14 Mar 2024 23:26:59 +0000 Received: by mail-pf1-x449.google.com with SMTP id d2e1a72fcca58-6e6b6de7383so1364649b3a.1 for ; Thu, 14 Mar 2024 16:26:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710458807; x=1711063607; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=f7mdClvgIXUuf9+yuKM3CelLdMACw57Fq4PBdMk33ZU=; b=FKr/UEJz9/6of5OgPHXRYgthS0GtWiFBGb5E7uPyEmZkVyN8sbyYOOxJzGqvhSVvhx reG0SitYdSG/pN/szrJbvpQ1NF9mxb+rlNGDsWKYlkVIGPWbi3RHuAOxasYnZuuew46G TPvodtRGGR+qSDj6nW/4TzjOWFtY/eUJdCxFoRId1FFfZ42Ahlgt/0WjWyMHyPCYQV1s hIqLWFob1TOy0L+UBcVFyzoMJtaI32RVYalizq34znEZeglR47TsGBFUwES1UnU++KEu o3NVDBT5pcgHsFGoatZdBI6o9J3wp9NSexXEKwGw4OzBgBXcKn9Osc+m/wGcVuhbndPx tgJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710458807; x=1711063607; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f7mdClvgIXUuf9+yuKM3CelLdMACw57Fq4PBdMk33ZU=; b=CtBYp6WkDQRwjSg7q2nRZwhiv4de4jXDhJi5jVAC45nSxLczj7klp9khs/WywM2I1j UjiajBsxDb/OqewQp0m+DUjT+fgYpoqm3Sk4cNLBWJE6ky/j1xt29hM+Hlm30zHhe2JW Ua+xA2NeLjU5lhjwpxqBimy2KyvAqB2HbVJe42H5hXPtHxKwgjqFIYLuuDLD1pgHu5K7 Trbe0d18E7WO8wm6Ufz7SfAyCpJns+jVYZAE5Vmnk1ZhZW7tDTkgUepqbUgRLk+nuHOu VLCLZYs+Nr5OFAGWbmUZlok8hf2LGi1Dl+R8ryedSHLFGbJ/48ccqIgyebRrfXpVy+Gy FXuA== X-Forwarded-Encrypted: i=1; AJvYcCX5x555Hug1f/BxbxO75BdbARuQFh1K9bbApF2Oh7Rxag4lhlA75USI72EeeLgEkHibYki9CpkVYCkUpobtMPXJ8ZKzWGOEkEBgGsFeSw== X-Gm-Message-State: AOJu0YzlZ82K7EPhhOp5E6ALkz1oQwhoH9n9eBdhLuhuiPoJa66RmRX6 2zWylw1PF3i8bvB1fqZ3hDf+HG9CUQvu1lbYpOUJaE9jSg3/UvCbqtOS4cXtnNjKPotI9XS4avJ 30Q== X-Google-Smtp-Source: AGHT+IHP+9uB+bS3/lKcsyk7/8c0Ce59jwpM+G35vfnwrWKSRS2+iNaQrX8dqel6o4dt3H0Nsgf9UIQa3fs= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:1a:b0:6e6:eefe:945d with SMTP id h26-20020a056a00001a00b006e6eefe945dmr9863pfk.0.1710458807233; Thu, 14 Mar 2024 16:26:47 -0700 (PDT) Date: Thu, 14 Mar 2024 16:26:23 -0700 In-Reply-To: <20240314232637.2538648-1-seanjc@google.com> Mime-Version: 1.0 References: <20240314232637.2538648-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.291.gc1ea87d7ee-goog Message-ID: <20240314232637.2538648-5-seanjc@google.com> Subject: [PATCH 04/18] KVM: selftests: Fix off-by-one initialization of GDT limit From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Ackerley Tng X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240314_162652_284980_666DA8FB X-CRM114-Status: GOOD ( 10.95 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Ackerley Tng Fix an off-by-one bug in the initialization of the GDT limit, which as defined in the SDM is inclusive, not exclusive. Note, vcpu_init_descriptor_tables() gets the limit correct, it's only vcpu_setup() that is broken, i.e. only tests that _don't_ invoke vcpu_init_descriptor_tables() can have problems. And the fact tha [...] Content analysis details: (-7.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:449 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM welcome-list -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 T_SCC_BODY_TEXT_LINE No description available. -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Ackerley Tng Fix an off-by-one bug in the initialization of the GDT limit, which as defined in the SDM is inclusive, not exclusive. Note, vcpu_init_descriptor_tables() gets the limit correct, it's only vcpu_setup() that is broken, i.e. only tests that _don't_ invoke vcpu_init_descriptor_tables() can have problems. And the fact that KVM effectively initializes the GDT twice will be cleaned up in the near future. Signed-off-by: Ackerley Tng [sean: rewrite changelog] Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c index 45f965c052a1..eaeba907bb53 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -522,7 +522,7 @@ static void kvm_setup_gdt(struct kvm_vm *vm, struct kvm_dtable *dt) vm->arch.gdt = __vm_vaddr_alloc_page(vm, MEM_REGION_DATA); dt->base = vm->arch.gdt; - dt->limit = getpagesize(); + dt->limit = getpagesize() - 1; } static void kvm_setup_tss_64bit(struct kvm_vm *vm, struct kvm_segment *segp,