From patchwork Thu Mar 14 23:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13592943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6CE2AC54E69 for ; Fri, 15 Mar 2024 00:32:05 +0000 (UTC) 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=7eMDQSKOz1GtywSe6hvFvTx00+XswM1o/BrCUD+IcAw=; b=Bfnz/gigO3Vdrx O5I6/nqVFDrcvI/OF3lZMZgye7eRoTzEri7v42q5+Zz4T1nOZCScyiMuXlb4jj8co+P+ruKXnNCkq RZTtqDjYkxUxEUmMwg8yOc2cwpcF4heI5UBqpb4YUmC4xd8drfaX8jJXY8lYcSc56Y34/UBGCFf5d h2lbxJDPAs8Wv1oS9lhT+D4Nq5ZSrjmOvI9tlYX86z1zq5x13RdYhlZBoDa6TKf7OdI4PPlUNctXH 52yT9hBaf4FIUXOeZ2y579tgEyq/60F4r4EDJt/wFoHvyt9VlJnJXafJDOgcLGGwSbyphcnZgpbcH btcc8rpIrzJG1qs4kjvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkvUS-0000000GAoS-3awY; Fri, 15 Mar 2024 00:32:04 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkuTY-0000000G06t-1vQm for linux-arm-kernel@lists.infradead.org; Thu, 14 Mar 2024 23:27:09 +0000 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dced704f17cso2438437276.1 for ; Thu, 14 Mar 2024 16:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710458820; x=1711063620; 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=j/j/mb3JtyoyPDhLhkSAITq95aQFSMlle8Dlg66amAk=; b=z+NwZM8rEaod+rOFkd4il6htFvTamKopwVg2NVZWxF/tpYh4hhfPtW+82qgct8iSz2 y56BtS2yG8AuUkKKKD1qU/L7rNfoLC3ydjjpT1iSLIDZ8cCh23xIZXxOSbIEsQx48mBp D67l2vlkR2u0mGw2Wf3kCvcOX31o6cUJmmuFlDFjCmTqa7257HO0+fQa5PfZ/Cu5Vj0Z uQVeTaMoVwT3d6LMzpvSCfjvomQuUwhNraBq45kbAwzf3H1oueOTLru6aR0LDOMXgniE Y8MOAFpQCvg19lAdWXZUeKiOTtKrZ+WramgCyV+M/tNVmrLkndpq5bN8Y/2P0bybQGAq ZdeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710458820; x=1711063620; 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=j/j/mb3JtyoyPDhLhkSAITq95aQFSMlle8Dlg66amAk=; b=eCB18iyIJreF4L79c+jdWocNl/7fDfhdJ2NEyeQZGgBEpmZ4kd3C4PXC+vstPFCm2i a9alKQDXcRKGiONzYvwJsjILN9bpyZw4wypv4zWY71KNsTwCN9fw6wyTxz34OjIZGbHO k3K4VJvISIvHmLnaRVHKfDeAJJcq/vAmHgOxITmkVkGkgIl9oNnLnu8BWOtgRDQKltAf VcoqylNIcjg6BlR8KUiaZ4ni4m+NXHzIhgqmmBvhNYt/IGgkVZ72jpd5ueIf5m5auf/v PzstXspK6mln4pTE/ti9d1ei4Xsu3jNg3O4wHLFglR5EH7Dg7zdYL3wjgs4ckqePdwSk cbtg== X-Gm-Message-State: AOJu0Yw5W0eRJDefB5yFp3QNeCZGiCTdFhze7mnQEWJZsCrvAyf0bv74 JO8WhS3HahMrzHJng7y4pNeFTDnRGoGXbBLeRXSIPO1ElrdFTVxbsD9EOFDWUo7s8o7XkCUdC17 n2g== X-Google-Smtp-Source: AGHT+IEgFldUzAavXJ42YJM5+Q6BHlgBbuisK5vIFOhA5ma+0WFPVDRLg0oxmN/Zi21+BucUmJd5KHT651s= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:72e:b0:dcc:94b7:a7a3 with SMTP id l14-20020a056902072e00b00dcc94b7a7a3mr183110ybt.12.1710458820208; Thu, 14 Mar 2024 16:27:00 -0700 (PDT) Date: Thu, 14 Mar 2024 16:26:30 -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-12-seanjc@google.com> Subject: [PATCH 11/18] KVM: selftests: Map x86's exception_handlers at VM creation, not vCPU setup 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_162704_666115_F57B69AD X-CRM114-Status: GOOD ( 10.59 ) X-BeenThere: linux-arm-kernel@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: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Map x86's exception handlers at VM creation, not vCPU setup, as the mapping is per-VM, i.e. doesn't need to be (re)done for every vCPU. Signed-off-by: Sean Christopherson Reviewed-by: Ackerley Tng --- tools/testing/selftests/kvm/lib/x86_64/processor.c | 3 ++- 1 file changed, 2 insertions(+), 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 5813d93b2e7c..f4046029f168 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -552,7 +552,6 @@ static void vcpu_init_descriptor_tables(struct kvm_vcpu *vcpu) sregs.gdt.limit = getpagesize() - 1; kvm_seg_set_kernel_data_64bit(NULL, DEFAULT_DATA_SELECTOR, &sregs.gs); vcpu_sregs_set(vcpu, &sregs); - *(vm_vaddr_t *)addr_gva2hva(vm, (vm_vaddr_t)(&exception_handlers)) = vm->handlers; } static void vcpu_init_sregs(struct kvm_vm *vm, struct kvm_vcpu *vcpu) @@ -651,6 +650,8 @@ static void vm_init_descriptor_tables(struct kvm_vm *vm) for (i = 0; i < NUM_INTERRUPTS; i++) set_idt_entry(vm, i, (unsigned long)(&idt_handlers)[i], 0, DEFAULT_CODE_SELECTOR); + + *(vm_vaddr_t *)addr_gva2hva(vm, (vm_vaddr_t)(&exception_handlers)) = vm->handlers; } void vm_install_exception_handler(struct kvm_vm *vm, int vector,