From patchwork Mon Feb 26 14:35:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 206750 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2158106dyb; Mon, 26 Feb 2024 07:41:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV/YOM1dHjLiXzIlfxndjNPImNBkS1BGLmz5imILYATadjqvgJTArSa6dap3tdcfVYbjf3paWrWt1Oi8RX2I6inacsXQw== X-Google-Smtp-Source: AGHT+IHXRFwbOcVZ44MnRjZsNEVYrFrRqMpMsmzMQ5G1/AKBaJJX7/SGd4dhtmAzAi+Yld5oQCDi X-Received: by 2002:a17:90a:9a4:b0:29a:6678:f7d3 with SMTP id 33-20020a17090a09a400b0029a6678f7d3mr4521992pjo.42.1708962072276; Mon, 26 Feb 2024 07:41:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708962072; cv=pass; d=google.com; s=arc-20160816; b=PdOXV/5STW0X/ddfOYAlJI5CkxIelpjE1wbYkG1ciiQGhUzM+sM9E365YEbIMapgBA TSzO7yc23l4zcIEtHDR1bM+2+wTKQL3qQ8UGPaO2M5+iWRweruW5KFmG8Z12s8uyNLWb UzPrbLC1YfxHqDAcM+PQYGkAQ6lzxjKP/UqmKPNOkY0KY2s6QU4w23SqRQgT4xSA5VTE pZEssGkkFRhIHy5GUv0WtAn616wri1vBgr4J2K0VeqFjf7CVn0pcwlp7cgkVJCjk+2Y4 b87ycb3oQ/YBUxM788V4VSzdC2bnxD4+cJTQSB31RKgIFPLmJCP+Dx8ygAqd+OfKyllg 2aMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0jozFDje0mLN9coijYdqOvVfSSMDTpV9h2OeBFaDVOU=; fh=YfMQA7cYBLmGod9w56nOCVb71J5cNiN9paNpUsV8AVo=; b=IEp98zv2F6DY1BxljgGtprkJPkvxCvFZhF5Apd+pYyz9mvy1pg+Y+eIYF6+tBNIfVj 9qgSza6WkKwqmtedKQkpKqq1gd/0J9ljuuyf+BI+wKjaMqbQCAPm8HXDWwb9DGuej4GT cfeJNa48aoFF/IhUOAbGY1P136ARtv9W3KwB8/patEdw4NrH2lZhdke4XNCgDnAICwRR NwH7zH8zAIVysf2AH1ig64bMmitJh3PwRoB0DV/wfVg+Yb9GXwD7kVLD9ZDpcbba4Vhc LMBTtGn3zHSxAB13pPfrRZvOrjotb2NELjGK+/TC9rDkXCwXHuu8dQ6xWLA1ZL6HM4UD T2CA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UXBfCvkY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-81669-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81669-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id mi13-20020a17090b4b4d00b0029958f76832si3981449pjb.179.2024.02.26.07.41.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 07:41:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81669-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UXBfCvkY; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-81669-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81669-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5F6B8B2D56B for ; Mon, 26 Feb 2024 14:45:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD25912C7F4; Mon, 26 Feb 2024 14:36:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UXBfCvkY" Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AE4A13399F; Mon, 26 Feb 2024 14:36:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708958162; cv=none; b=EMUWJqLhN62GUxv3++vPOL/j61Ub923cDG2tRAFOONJz3UhtYxdNTErtZhVkL+9IaCbJJxNhJMePAaOAbY9tcwKwq/qmbOIm7wWm3n8m4NciaSir0j1vVXDWHpo/v14GCwGUzfGUJmFueqLzfCoMzg5Vv4icW7nrdCJwveEnylI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708958162; c=relaxed/simple; bh=pkXKcagVoUrfls8IZw2n6mmAXzIWVwR2aUX+9PNq4Ls=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eodqSTfeuuP3TuUdDvUtmyNGCs4c09SWZYcfOSgZw4bFI4YIVkTQkIUhu6clYIPi+Ihaft1QlAhr2GZUiO8jNkuZDsqm5LTVm3mXmHXbG1X236XfEVVdYcnRQ4npX+y9tFR5Qrcme5CZiLA6E3GowPeR9o0/m1tRaG4oKIZjOk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UXBfCvkY; arc=none smtp.client-ip=209.85.215.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5d42e7ab8a9so2021669a12.3; Mon, 26 Feb 2024 06:36:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708958160; x=1709562960; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0jozFDje0mLN9coijYdqOvVfSSMDTpV9h2OeBFaDVOU=; b=UXBfCvkYIvmIvIACUAcHD7+X/wXG9DEXmEpNshxYTOvRnKa+OsjmwvwEEgo8A91pJb b2fU7/N6YFUbrDcFynuHLJSoPQjSeRvsW1zkhIPfMKU5tNg8KMg52Th5c0s8jYtCpBeW NwkS3TRNdeI0MhUT5e0E/BtYeIMmOHeH9Ia4uJY5Hy5NY4QmFE8YsaHvLekc3Y09mNIu qwy2lJXgCNwEh6bxJzvrgNJtRyMlVooCjBEUgsshBzM3JzOklkhe8R1rK+9A0HaTAjUH /gPZ/Trn4cDtR4ZeP/yDKeNQV8QwqN/+92WCwm8lItYHdaBNZfFTXuYgeom2+pOiDdq8 8mqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708958160; x=1709562960; 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=0jozFDje0mLN9coijYdqOvVfSSMDTpV9h2OeBFaDVOU=; b=TjnvCL9zJFCYTAqYTgbNT9OfCCWUtKCesrY/g1lbDZeyAKspdK1svCsOoZW39PttX+ spe4jEVH7m2Q8Uye+sZU1SdNw6LPI7UXsn4Gsi4aaX3EE/Y5FaMvBi96lw2cDZNbZ+c7 rOgNlQE1hF47I0LHOe6johOWRuEIYQkIDbtyW4AAHUU2uoWQ848JrJ8U4jt+0rk7STKz a43LX5CXnOEwqdnrftcpi33moON9z498vk2ql9xFy5weAXAdUYDuMcS/HWNSG5P9eROa u3d9/Ia0Js5t7auJkQrI8k1K0UondgR6DMroh4yc+RLHKdFugppkrEX8RayD7xQee3uF N/Tw== X-Forwarded-Encrypted: i=1; AJvYcCXvi39gVkVMzgOziQuOjdc32ps17mAZ7pYFZw9mwMMUI8hqgcOoBDAyHG1GbTrfs27PLL/SNgH4X5E6jnspARQKUL6A X-Gm-Message-State: AOJu0YxsUs+3dmGACIU4wh0XtRcU/UogleGxtX42P9VciWgnTQtUNbSn MppvpGHktw9wy9k+IOeMw8uUWy5zpf19s2F28uvJYk8GkRn5YSIuyoPE5ZTI X-Received: by 2002:a17:90a:db86:b0:29a:2860:28b9 with SMTP id h6-20020a17090adb8600b0029a286028b9mr4563991pjv.48.1708958159681; Mon, 26 Feb 2024 06:35:59 -0800 (PST) Received: from localhost ([47.88.5.130]) by smtp.gmail.com with ESMTPSA id sw8-20020a17090b2c8800b0029abf47ec7fsm2333867pjb.0.2024.02.26.06.35.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2024 06:35:59 -0800 (PST) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Lai Jiangshan , Hou Wenlong , Linus Torvalds , Peter Zijlstra , Sean Christopherson , Thomas Gleixner , Borislav Petkov , Ingo Molnar , kvm@vger.kernel.org, Paolo Bonzini , x86@kernel.org, Kees Cook , Juergen Gross , Dave Hansen , "H. Peter Anvin" Subject: [RFC PATCH 25/73] KVM: x86/PVM: Implement APIC emulation related callbacks Date: Mon, 26 Feb 2024 22:35:42 +0800 Message-Id: <20240226143630.33643-26-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20240226143630.33643-1-jiangshanlai@gmail.com> References: <20240226143630.33643-1-jiangshanlai@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791976613808927118 X-GMAIL-MSGID: 1791976613808927118 From: Lai Jiangshan For PVM, APIC virtualization for the guest is supported by reusing APIC emulation. Signed-off-by: Lai Jiangshan Signed-off-by: Hou Wenlong --- arch/x86/kvm/pvm/pvm.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/x86/kvm/pvm/pvm.c b/arch/x86/kvm/pvm/pvm.c index 3735baee1d5f..ce047d211657 100644 --- a/arch/x86/kvm/pvm/pvm.c +++ b/arch/x86/kvm/pvm/pvm.c @@ -566,6 +566,25 @@ static int pvm_get_cpl(struct kvm_vcpu *vcpu) return 3; } +static void pvm_deliver_interrupt(struct kvm_lapic *apic, int delivery_mode, + int trig_mode, int vector) +{ + struct kvm_vcpu *vcpu = apic->vcpu; + + kvm_lapic_set_irr(vector, apic); + kvm_make_request(KVM_REQ_EVENT, vcpu); + kvm_vcpu_kick(vcpu); +} + +static void pvm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu) +{ +} + +static bool pvm_apic_init_signal_blocked(struct kvm_vcpu *vcpu) +{ + return false; +} + static void pvm_setup_mce(struct kvm_vcpu *vcpu) { } @@ -1083,19 +1102,25 @@ static struct kvm_x86_ops pvm_x86_ops __initdata = { .vcpu_pre_run = pvm_vcpu_pre_run, .vcpu_run = pvm_vcpu_run, .handle_exit = pvm_handle_exit, + .refresh_apicv_exec_ctrl = pvm_refresh_apicv_exec_ctrl, + .deliver_interrupt = pvm_deliver_interrupt, .vcpu_after_set_cpuid = pvm_vcpu_after_set_cpuid, .handle_exit_irqoff = pvm_handle_exit_irqoff, + .request_immediate_exit = __kvm_request_immediate_exit, + .sched_in = pvm_sched_in, .nested_ops = &pvm_nested_ops, .setup_mce = pvm_setup_mce, + .apic_init_signal_blocked = pvm_apic_init_signal_blocked, .msr_filter_changed = pvm_msr_filter_changed, .complete_emulated_msr = kvm_complete_insn_gp, + .vcpu_deliver_sipi_vector = kvm_vcpu_deliver_sipi_vector, }; static struct kvm_x86_init_ops pvm_init_ops __initdata = {