From patchwork Wed Oct 18 16:37:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=b1dtBXFb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c6n16kNz20cx for ; Thu, 19 Oct 2023 03:41:05 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9YC-0000vG-AR; Wed, 18 Oct 2023 12:37:40 -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 1qt9Y9-0000uh-GB for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt9Y8-0007NC-25 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647055; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WbMj+5RWahTieDRbcX5DC9e5dLRHLHSOEQ+5tZ4A9v0=; b=b1dtBXFb7RWDjWZFzIoickq9J6q+G1kXqQarfKYuM31w/IvLBm61VSeHTZKy56YUADQhiP S6sFgrD4calprmA20KiAm5d43x9cPg2fHUOUV6zagUyRzgb6c9qqMimLhC5k+yt4/od8F9 yHNmrZYzN/MtKaw5ZoLeG9hcBmJAbSY= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-475-L_7WRaMkMv6QFnuaMIhs0w-1; Wed, 18 Oct 2023 12:37:33 -0400 X-MC-Unique: L_7WRaMkMv6QFnuaMIhs0w-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9ae57d8b502so526188966b.2 for ; Wed, 18 Oct 2023 09:37:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647052; x=1698251852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WbMj+5RWahTieDRbcX5DC9e5dLRHLHSOEQ+5tZ4A9v0=; b=ET3ERji/mE8rCUtUmm8lk2vUMFyE0vBj4X4MZkvUqk0BfUecA+mp8eRMt5p5amjEUj zZFQjy14HeDcTaUnSJ3YgM4Lt1RI/U0gmjV+N/vVBX3Bp0BU7FkFJJiyiRSAgUUADxYU GrqZJs6UvXeCr4/ny9WFyjNKX0vR6I55vykkh0MvtAy66Zgj00NspIoGRcIBOR0wVhQn ekfkTxISGJX3Cy4Y3BnIyZ1KjpDzA24MgAWzliVzKFGBJ6fellcaO8qJpkTCHakOd2My gT0bnK6UTsJDfKZ8iJxSJFgmBVxUDeyFwAhwRK8u8Jdb8mM0ygWvEC1RSE+m+i1ujus/ IrnA== X-Gm-Message-State: AOJu0YxSBsML9AENQJh+mijAfYXsXfFnpekBMismf9gMHnMljAij+Vll aEtaYs1RhpgFF6ZjKdVAodsM9MdbJiJ6QRCaRjb11nRkho4+URCNSApYLJdwoIbK41LXDN6IYtZ eUsjD9x7UpAnd6iyjYhpzHcyj6eyrthCBvmEMug045zE5eLlVwV2lK9L5/umHA3r2hf4A3AJ19F 4= X-Received: by 2002:a17:907:7f20:b0:9b9:f46f:8925 with SMTP id qf32-20020a1709077f2000b009b9f46f8925mr4540526ejc.48.1697647052444; Wed, 18 Oct 2023 09:37:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGw3xiJ9kFUcOpikAjgpAbqM9ZAplu6mdOSrV3heUeQ4mzgcX85fI9D4F3qr2Vb18qhBvb5rg== X-Received: by 2002:a17:907:7f20:b0:9b9:f46f:8925 with SMTP id qf32-20020a1709077f2000b009b9f46f8925mr4540513ejc.48.1697647052198; Wed, 18 Oct 2023 09:37:32 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id i24-20020a1709061cd800b009ad8d444be4sm2008437ejh.43.2023.10.18.09.37.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:31 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 01/17] kvm: remove unnecessary stub Date: Wed, 18 Oct 2023 18:37:12 +0200 Message-ID: <20231018163728.363879-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.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.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This function is only invoked from hw/intc/s390_flic_kvm.c, and therefore only if CONFIG_KVM is defined. Signed-off-by: Paolo Bonzini Reviewed-by: Manos Pitsidianakis --- accel/stubs/kvm-stub.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 51f522e52e8..a323252f8e2 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -92,11 +92,6 @@ void kvm_irqchip_change_notify(void) { } -int kvm_irqchip_add_adapter_route(KVMState *s, AdapterInfo *adapter) -{ - return -ENOSYS; -} - int kvm_irqchip_add_irqfd_notifier_gsi(KVMState *s, EventNotifier *n, EventNotifier *rn, int virq) { From patchwork Wed Oct 18 16:37:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851040 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=V4Qgqp4l; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c3y26Fqz20Pd for ; Thu, 19 Oct 2023 03:38:38 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9YI-0000vx-Ea; Wed, 18 Oct 2023 12:37:46 -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 1qt9YG-0000ve-AX for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:44 -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 1qt9YE-0007NW-Ux for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647062; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L4DzlN4wlvBrrC7R/mPs5UhfL8TuwbZ//Pi97xqHTxw=; b=V4Qgqp4lVt5XGSISjUzGxQPGbMl2eyLVzjx+nLWvZYEHwo6PxW0VwqK5fcXqTNH92x6ohE gXS9qv/Fgg9L24N4JRcJRF07emJi/WrKMMD3l4y1xnRthTXCMXxOYEEFRq4x/vK7cNhK5l ZYGFMONZbYeHiOt4Isr5mQSdzwSy5vE= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-78-_b5xdo-NOluDxhp90JsZ3A-1; Wed, 18 Oct 2023 12:37:39 -0400 X-MC-Unique: _b5xdo-NOluDxhp90JsZ3A-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9b65c46bca8so227867166b.1 for ; Wed, 18 Oct 2023 09:37:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647054; x=1698251854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L4DzlN4wlvBrrC7R/mPs5UhfL8TuwbZ//Pi97xqHTxw=; b=TgEPhpQtABmPQ1kplhFTsXZ7HuJhCnCyq+DQuVnFKdslRqbFGG/Eqw+RqklcpXY+IG uUByUv99mmJTBz9FmGwcFO138oPpO7zuTPm+mvoxM4E8Lj0LkJkgb1ZNVL1XL46gPYJP XBtKVZEd4T4y2M4/LDCwrMiRZaGcHfZy971+RAlguAQsP2AAI/NWCbyEvvegzZpI39Sv e7+lqUdliawRMCPdL2eI9Rv0btR5DMUQzU5in8uP+JBaYi2dEo7qYwTbbyfJ99QY8w/O 63ze3smqtQ51gGb8Y0RE0tVwhd0I9uLq8iO0wk4xg09Kqnx7HlN1XChyTJNAk7oGl8xt Lp7A== X-Gm-Message-State: AOJu0Yydr3GCGfDs4/JtiT1/x/jqHddje1PYDfaOZUdlnIifZAZm5QnT NV4Ib5cJL80JSxBwiOzMzqi+6DcAnONMZKmbLPbEmktheoZeItbNLKjyCuHLgYlY0qzyoT1nCjV v0f3DmcVNUp+eBvzKoDMcvDsF3LF0qIg8LRRALY0UIv8BDvoJexYLiSfLWSMlWu3sU2fB+LYhIO M= X-Received: by 2002:a17:907:980c:b0:9bf:5df1:38c9 with SMTP id ji12-20020a170907980c00b009bf5df138c9mr4412959ejc.9.1697647054250; Wed, 18 Oct 2023 09:37:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpRGXSM0MNXP35NsmKwQR4Ob7XHolnv20FAjRwEqRwvndKyreYR0nngBzs1oh1EXwj7kt+Pw== X-Received: by 2002:a17:907:980c:b0:9bf:5df1:38c9 with SMTP id ji12-20020a170907980c00b009bf5df138c9mr4412941ejc.9.1697647053737; Wed, 18 Oct 2023 09:37:33 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id c12-20020a17090603cc00b009adce1c97ccsm1957335eja.53.2023.10.18.09.37.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 02/17] kvm: require KVM_CAP_INTERNAL_ERROR_DATA Date: Wed, 18 Oct 2023 18:37:13 +0200 Message-ID: <20231018163728.363879-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This was introduced in KVM in Linux 2.6.33, we can require it unconditionally. Signed-off-by: Paolo Bonzini Reviewed-by: Manos Pitsidianakis --- accel/kvm/kvm-all.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 3f7eafe08cb..8eee5042252 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -111,6 +111,7 @@ static const KVMCapabilityInfo kvm_required_capabilites[] = { KVM_CAP_INFO(USER_MEMORY), KVM_CAP_INFO(DESTROY_MEMORY_REGION_WORKS), KVM_CAP_INFO(JOIN_MEMORY_REGIONS_WORKS), + KVM_CAP_INFO(INTERNAL_ERROR_DATA), KVM_CAP_LAST_INFO }; @@ -2794,16 +2795,14 @@ static void kvm_handle_io(uint16_t port, MemTxAttrs attrs, void *data, int direc static int kvm_handle_internal_error(CPUState *cpu, struct kvm_run *run) { + int i; + fprintf(stderr, "KVM internal error. Suberror: %d\n", run->internal.suberror); - if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) { - int i; - - for (i = 0; i < run->internal.ndata; ++i) { - fprintf(stderr, "extra data[%d]: 0x%016"PRIx64"\n", - i, (uint64_t)run->internal.data[i]); - } + for (i = 0; i < run->internal.ndata; ++i) { + fprintf(stderr, "extra data[%d]: 0x%016"PRIx64"\n", + i, (uint64_t)run->internal.data[i]); } if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) { fprintf(stderr, "emulation failure\n"); From patchwork Wed Oct 18 16:37:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851045 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aIjKGGBn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c3z6sCqz23jS for ; Thu, 19 Oct 2023 03:38:39 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9YP-0000y9-S1; Wed, 18 Oct 2023 12:37:55 -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 1qt9YN-0000xJ-Se for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:52 -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 1qt9YL-0007OP-O1 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SiR4nK8JAQRzovTn0TwDjm9ckV/18tAq1r192VX2Ckc=; b=aIjKGGBn7q4E30CS6dNNJY1MuxMAZTmL1eXE8DXne90TgSRO5gHE0rMng0bRa1eC2mCgkm KObNAc8BtlXQV/QZ4OplsYHCjasY5adakkXrB326UkEw/YwUHlZtXjDA5hQ7h+U6vL7et5 O0fyd0qqdCA/NZ+c7iNW6gyjjQTNeWQ= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-ZsVqpbRqOeC6zwk963gpXw-1; Wed, 18 Oct 2023 12:37:37 -0400 X-MC-Unique: ZsVqpbRqOeC6zwk963gpXw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-993eeb3a950so471029266b.2 for ; Wed, 18 Oct 2023 09:37:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647056; x=1698251856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SiR4nK8JAQRzovTn0TwDjm9ckV/18tAq1r192VX2Ckc=; b=I+7TtaWq4mruFZzQbllW3h25tsG6iVMHLuKRtkGPaHyIHX3pf1FuUQgko4VWHdj0IU Lk5XY16R4sScElfo2aehDWgqVEB6wFtpEyoO6TaG1R/u4NhJ1umO2MA+VNoa22zn3pWz CSxhLloWZSrcnZ3mY70I7EZ0DW3W+BVhRS+/D5d8nQ6C7iPiww3F/3sRYY5beLX/lVbR cDW9ghVNqkMNb/2H5+goIy5KkRSMWWiI+1gVOaAjVZ8NdHfwi+P4GmnSo+gtJGnCOTkh aS8vJMwW9eRVWdKVfSToO2uUfvgPocU+Ut907dVwm/O6wlNCLZZCVe6nfDmnslV2hQyK 7wFw== X-Gm-Message-State: AOJu0YymXDfMKhnl6jPXGK0KNK61KLkIenobV4gLVnVVDKcfV1D78k7E gPm9PKqFKb5YlwUD09OAMN7MqmdJIvnhtrzgPdb5vEkorGt7loAmF6012ucjlk4FXW1bx15NYzV F+V8PxvGztpxw/ym10rEKLCTxXuL2HoNEn0o4TamqTwM+Z9SYrzKg6pGdyEYEaK9l/mfoiwk/cZ 8= X-Received: by 2002:a17:906:ee86:b0:9be:cdca:dae9 with SMTP id wt6-20020a170906ee8600b009becdcadae9mr4588610ejb.36.1697647055844; Wed, 18 Oct 2023 09:37:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsVsvwM8AftE624x8/7EsDbNLyTKsH42sL7YhGWsGCoBbDPPXgZ/gHL9kBMXlGoCd4RusZQA== X-Received: by 2002:a17:906:ee86:b0:9be:cdca:dae9 with SMTP id wt6-20020a170906ee8600b009becdcadae9mr4588595ejb.36.1697647055496; Wed, 18 Oct 2023 09:37:35 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id b19-20020a170906d11300b0098921e1b064sm1991580ejz.181.2023.10.18.09.37.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 03/17] kvm: require KVM_CAP_SIGNAL_MSI Date: Wed, 18 Oct 2023 18:37:14 +0200 Message-ID: <20231018163728.363879-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This was introduced in KVM in Linux 3.5, we can require it unconditionally in kvm_irqchip_send_msi(). However, not all architectures have to implement it so check it only in x86, the only architecture that ever had MSI injection but not KVM_CAP_SIGNAL_MSI. ARM uses it to detect the presence of the ITS emulation in the kernel, introduced in Linux 4.8. Assume that it's there and possibly fail when realizing the arm-its-kvm device. Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 102 +++------------------------------ accel/stubs/kvm-stub.c | 1 - hw/intc/arm_gicv3_its_common.c | 3 +- include/sysemu/kvm.h | 9 --- include/sysemu/kvm_int.h | 1 - target/i386/kvm/kvm.c | 1 + 6 files changed, 9 insertions(+), 108 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 8eee5042252..0c7b0569da4 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -99,7 +99,6 @@ bool kvm_gsi_direct_mapping; bool kvm_allowed; bool kvm_readonly_mem_allowed; bool kvm_vm_attributes_allowed; -bool kvm_direct_msi_allowed; bool kvm_ioeventfd_any_length_allowed; bool kvm_msi_use_devid; bool kvm_has_guest_debug; @@ -1848,7 +1847,7 @@ static void clear_gsi(KVMState *s, unsigned int gsi) void kvm_init_irq_routing(KVMState *s) { - int gsi_count, i; + int gsi_count; gsi_count = kvm_check_extension(s, KVM_CAP_IRQ_ROUTING) - 1; if (gsi_count > 0) { @@ -1860,12 +1859,6 @@ void kvm_init_irq_routing(KVMState *s) s->irq_routes = g_malloc0(sizeof(*s->irq_routes)); s->nr_allocated_irq_routes = 0; - if (!kvm_direct_msi_allowed) { - for (i = 0; i < KVM_MSI_HASHTAB_SIZE; i++) { - QTAILQ_INIT(&s->msi_hashtab[i]); - } - } - kvm_arch_init_irq_routing(s); } @@ -1985,41 +1978,10 @@ void kvm_irqchip_change_notify(void) notifier_list_notify(&kvm_irqchip_change_notifiers, NULL); } -static unsigned int kvm_hash_msi(uint32_t data) -{ - /* This is optimized for IA32 MSI layout. However, no other arch shall - * repeat the mistake of not providing a direct MSI injection API. */ - return data & 0xff; -} - -static void kvm_flush_dynamic_msi_routes(KVMState *s) -{ - KVMMSIRoute *route, *next; - unsigned int hash; - - for (hash = 0; hash < KVM_MSI_HASHTAB_SIZE; hash++) { - QTAILQ_FOREACH_SAFE(route, &s->msi_hashtab[hash], entry, next) { - kvm_irqchip_release_virq(s, route->kroute.gsi); - QTAILQ_REMOVE(&s->msi_hashtab[hash], route, entry); - g_free(route); - } - } -} - static int kvm_irqchip_get_virq(KVMState *s) { int next_virq; - /* - * PIC and IOAPIC share the first 16 GSI numbers, thus the available - * GSI numbers are more than the number of IRQ route. Allocating a GSI - * number can succeed even though a new route entry cannot be added. - * When this happens, flush dynamic MSI entries to free IRQ route entries. - */ - if (!kvm_direct_msi_allowed && s->irq_routes->nr == s->gsi_count) { - kvm_flush_dynamic_msi_routes(s); - } - /* Return the lowest unused GSI in the bitmap */ next_virq = find_first_zero_bit(s->used_gsi_bitmap, s->gsi_count); if (next_virq >= s->gsi_count) { @@ -2029,63 +1991,17 @@ static int kvm_irqchip_get_virq(KVMState *s) } } -static KVMMSIRoute *kvm_lookup_msi_route(KVMState *s, MSIMessage msg) -{ - unsigned int hash = kvm_hash_msi(msg.data); - KVMMSIRoute *route; - - QTAILQ_FOREACH(route, &s->msi_hashtab[hash], entry) { - if (route->kroute.u.msi.address_lo == (uint32_t)msg.address && - route->kroute.u.msi.address_hi == (msg.address >> 32) && - route->kroute.u.msi.data == le32_to_cpu(msg.data)) { - return route; - } - } - return NULL; -} - int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) { struct kvm_msi msi; - KVMMSIRoute *route; - if (kvm_direct_msi_allowed) { - msi.address_lo = (uint32_t)msg.address; - msi.address_hi = msg.address >> 32; - msi.data = le32_to_cpu(msg.data); - msi.flags = 0; - memset(msi.pad, 0, sizeof(msi.pad)); + msi.address_lo = (uint32_t)msg.address; + msi.address_hi = msg.address >> 32; + msi.data = le32_to_cpu(msg.data); + msi.flags = 0; + memset(msi.pad, 0, sizeof(msi.pad)); - return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi); - } - - route = kvm_lookup_msi_route(s, msg); - if (!route) { - int virq; - - virq = kvm_irqchip_get_virq(s); - if (virq < 0) { - return virq; - } - - route = g_new0(KVMMSIRoute, 1); - route->kroute.gsi = virq; - route->kroute.type = KVM_IRQ_ROUTING_MSI; - route->kroute.flags = 0; - route->kroute.u.msi.address_lo = (uint32_t)msg.address; - route->kroute.u.msi.address_hi = msg.address >> 32; - route->kroute.u.msi.data = le32_to_cpu(msg.data); - - kvm_add_routing_entry(s, &route->kroute); - kvm_irqchip_commit_routes(s); - - QTAILQ_INSERT_TAIL(&s->msi_hashtab[kvm_hash_msi(msg.data)], route, - entry); - } - - assert(route->kroute.type == KVM_IRQ_ROUTING_MSI); - - return kvm_set_irq(s, route->kroute.gsi, 1); + return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi); } int kvm_irqchip_add_msi_route(KVMRouteChange *c, int vector, PCIDevice *dev) @@ -2660,10 +2576,6 @@ static int kvm_init(MachineState *ms) s->max_nested_state_len = kvm_check_extension(s, KVM_CAP_NESTED_STATE); -#ifdef KVM_CAP_IRQ_ROUTING - kvm_direct_msi_allowed = (kvm_check_extension(s, KVM_CAP_SIGNAL_MSI) > 0); -#endif - s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3); s->irq_set_ioctl = KVM_IRQ_LINE; diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index a323252f8e2..bce005adad8 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -27,7 +27,6 @@ bool kvm_allowed; bool kvm_readonly_mem_allowed; bool kvm_ioeventfd_any_length_allowed; bool kvm_msi_use_devid; -bool kvm_direct_msi_allowed; void kvm_flush_coalesced_mmio_buffer(void) { diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c index abaf77057e1..fddd6d490c2 100644 --- a/hw/intc/arm_gicv3_its_common.c +++ b/hw/intc/arm_gicv3_its_common.c @@ -163,8 +163,7 @@ type_init(gicv3_its_common_register_types) const char *its_class_name(void) { if (kvm_irqchip_in_kernel()) { - /* KVM implementation requires this capability */ - return kvm_direct_msi_enabled() ? "arm-its-kvm" : NULL; + return "arm-its-kvm"; } else { /* Software emulation based model */ return "arm-gicv3-its"; diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 97a8a4f201c..93dccf5dd92 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -43,7 +43,6 @@ extern bool kvm_msi_via_irqfd_allowed; extern bool kvm_gsi_routing_allowed; extern bool kvm_gsi_direct_mapping; extern bool kvm_readonly_mem_allowed; -extern bool kvm_direct_msi_allowed; extern bool kvm_ioeventfd_any_length_allowed; extern bool kvm_msi_use_devid; @@ -147,13 +146,6 @@ extern bool kvm_msi_use_devid; */ #define kvm_readonly_mem_enabled() (kvm_readonly_mem_allowed) -/** - * kvm_direct_msi_enabled: - * - * Returns: true if KVM allows direct MSI injection. - */ -#define kvm_direct_msi_enabled() (kvm_direct_msi_allowed) - /** * kvm_ioeventfd_any_length_enabled: * Returns: true if KVM allows any length io eventfd. @@ -181,7 +173,6 @@ extern bool kvm_msi_use_devid; #define kvm_gsi_routing_allowed() (false) #define kvm_gsi_direct_mapping() (false) #define kvm_readonly_mem_enabled() (false) -#define kvm_direct_msi_enabled() (false) #define kvm_ioeventfd_any_length_enabled() (false) #define kvm_msi_devid_required() (false) diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 075939a3c4f..a7dacd12d6c 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -103,7 +103,6 @@ struct KVMState int nr_allocated_irq_routes; unsigned long *used_gsi_bitmap; unsigned int gsi_count; - QTAILQ_HEAD(, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE]; #endif KVMMemoryListener memory_listener; QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index ab72bcdfad1..ab7d39d5399 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -91,6 +91,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_INFO(SET_TSS_ADDR), KVM_CAP_INFO(EXT_CPUID), KVM_CAP_INFO(MP_STATE), + KVM_CAP_INFO(SIGNAL_MSI), KVM_CAP_LAST_INFO }; From patchwork Wed Oct 18 16:37:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OfNsy5zi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c7S17PDz20cx for ; Thu, 19 Oct 2023 03:41:40 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9YM-0000wr-F0; Wed, 18 Oct 2023 12:37:51 -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 1qt9YI-0000wC-SA for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:47 -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 1qt9YH-0007Nn-9O for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ouuDmH5LRXhpOLGzIT0yUziDNV9zDFXE5DW4RMtCLhc=; b=OfNsy5zidnWyY0BcMAz5aQHN4tDpDBwvML/w1EfQPpAhzHZbnRllrScN2jxUUXvnZ8e8/w hTWboLGQc7muyFDYxzLjeaVFaqjA7YS6MbJ5tYAbH2NRIX7o76aK8eNq1it3elMToBXjmL H4D4JRhHIr0eGFu4skW7NL6Pqs1bmZ0= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-208-MI1FNrJAMvCmMeoyUbIf5A-1; Wed, 18 Oct 2023 12:37:40 -0400 X-MC-Unique: MI1FNrJAMvCmMeoyUbIf5A-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9ae7663e604so307180566b.3 for ; Wed, 18 Oct 2023 09:37:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647057; x=1698251857; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ouuDmH5LRXhpOLGzIT0yUziDNV9zDFXE5DW4RMtCLhc=; b=qzFGGJYld1h2pSGiJDQgRDMZYgdZuLPqH8uuMyHk+rJsypmNYsnmeZZU5d4O34GpaC InxHmBqXIVyhr2Uo9Z7EC16TSLZyz92zzmerSRcFRjOXOid2GSPG8RcRLwOoL2yG+guo tTILyR+eFPcK5mNVX3qb1T/8V908VHn6CgJran98RS+j2pgmYdZZSmXOudb5H4Xiw7ZX i0WcdvBFKyh0Yp5u8W0taOXkv6wAtMmGx1RSN75qh4zN22yjShtxUyGFoHJMOcD6r3zK /uw3iZZ0WyikyAo1CUwAlUKdiwMBOy81RtpFFra6iL2ADitQgUQdcmVjON5t5v8/k8PU IhMg== X-Gm-Message-State: AOJu0YzmzqQdisJfko/+J2//scwJu14rRf2lBbBdBAvFnrgoPC+Mx4ly 3os1a6CQT0jC9vBoACdDnNL5qNCLkwZ+kpeBsgQAWRZZGwzAslHg9ytQoW5ALCd9O/xTvYse3rC conSCOdjpAWi1eBOpaPmztQDkDl0yDAXaHGgU5bRfq7/vTvL+lxU5dNYXupi35DmmkG0ruC3+h0 g= X-Received: by 2002:a17:906:9c84:b0:9a1:680e:8c54 with SMTP id fj4-20020a1709069c8400b009a1680e8c54mr4531002ejc.71.1697647057496; Wed, 18 Oct 2023 09:37:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwqnqFKFWSIznf+vTmV4FWwkWoskwg4iYqw68mDALQLcf2pk23jYhWJIbIesxUNLzfu11Vlg== X-Received: by 2002:a17:906:9c84:b0:9a1:680e:8c54 with SMTP id fj4-20020a1709069c8400b009a1680e8c54mr4530989ejc.71.1697647057161; Wed, 18 Oct 2023 09:37:37 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id mc8-20020a170906eb4800b0098d2d219649sm2006094ejb.174.2023.10.18.09.37.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 04/17] kvm: require KVM_CAP_IRQFD for kernel irqchip Date: Wed, 18 Oct 2023 18:37:15 +0200 Message-ID: <20231018163728.363879-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org KVM_CAP_IRQFD is always available on architectures that support an in-kernel interrupt controller, and was introduced in Linux 2.6.32. We can require it unconditionally. Signed-off-by: Paolo Bonzini Reviewed-by: Manos Pitsidianakis --- accel/kvm/kvm-all.c | 13 +++++-------- accel/stubs/kvm-stub.c | 1 - hw/intc/arm_gicv3_its_kvm.c | 2 +- include/sysemu/kvm.h | 6 +++--- target/riscv/kvm/kvm-cpu.c | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 0c7b0569da4..be50d47f7b4 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -91,7 +91,6 @@ bool kvm_split_irqchip; bool kvm_async_interrupts_allowed; bool kvm_halt_in_kernel_allowed; bool kvm_eventfds_allowed; -bool kvm_irqfds_allowed; bool kvm_resamplefds_allowed; bool kvm_msi_via_irqfd_allowed; bool kvm_gsi_routing_allowed; @@ -2128,10 +2127,6 @@ static int kvm_irqchip_assign_irqfd(KVMState *s, EventNotifier *event, } } - if (!kvm_irqfds_enabled()) { - return -ENOSYS; - } - return kvm_vm_ioctl(s, KVM_IRQFD, &irqfd); } @@ -2292,6 +2287,11 @@ static void kvm_irqchip_create(KVMState *s) return; } + if (kvm_check_extension(s, KVM_CAP_IRQFD) <= 0) { + fprintf(stderr, "kvm: irqfd not implemented\n"); + exit(1); + } + /* First probe and see if there's a arch-specific hook to create the * in-kernel irqchip for us */ ret = kvm_arch_irqchip_create(s); @@ -2589,9 +2589,6 @@ static int kvm_init(MachineState *ms) kvm_eventfds_allowed = (kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0); - kvm_irqfds_allowed = - (kvm_check_extension(s, KVM_CAP_IRQFD) > 0); - kvm_resamplefds_allowed = (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0); diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index bce005adad8..19d58f2778f 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -18,7 +18,6 @@ KVMState *kvm_state; bool kvm_kernel_irqchip; bool kvm_async_interrupts_allowed; bool kvm_eventfds_allowed; -bool kvm_irqfds_allowed; bool kvm_resamplefds_allowed; bool kvm_msi_via_irqfd_allowed; bool kvm_gsi_routing_allowed; diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c index 7eda9fb86ea..178f6d7de90 100644 --- a/hw/intc/arm_gicv3_its_kvm.c +++ b/hw/intc/arm_gicv3_its_kvm.c @@ -124,7 +124,7 @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp) kvm_msi_use_devid = true; kvm_gsi_direct_mapping = false; - kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled(); + kvm_msi_via_irqfd_allowed = true; } /** diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 93dccf5dd92..575dee53b39 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -37,7 +37,6 @@ extern bool kvm_split_irqchip; extern bool kvm_async_interrupts_allowed; extern bool kvm_halt_in_kernel_allowed; extern bool kvm_eventfds_allowed; -extern bool kvm_irqfds_allowed; extern bool kvm_resamplefds_allowed; extern bool kvm_msi_via_irqfd_allowed; extern bool kvm_gsi_routing_allowed; @@ -102,8 +101,10 @@ extern bool kvm_msi_use_devid; * Returns: true if we can use irqfds to inject interrupts into * a KVM CPU (ie the kernel supports irqfds and we are running * with a configuration where it is meaningful to use them). + * + * Always available if running with in-kernel irqchip. */ -#define kvm_irqfds_enabled() (kvm_irqfds_allowed) +#define kvm_irqfds_enabled() kvm_irqchip_in_kernel() /** * kvm_resamplefds_enabled: @@ -167,7 +168,6 @@ extern bool kvm_msi_use_devid; #define kvm_async_interrupts_enabled() (false) #define kvm_halt_in_kernel() (false) #define kvm_eventfds_enabled() (false) -#define kvm_irqfds_enabled() (false) #define kvm_resamplefds_enabled() (false) #define kvm_msi_via_irqfd_enabled() (false) #define kvm_gsi_routing_allowed() (false) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index 090d6176275..26e68c7ab45 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -1420,7 +1420,7 @@ void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift, exit(1); } - kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled(); + kvm_msi_via_irqfd_allowed = true; } static void kvm_cpu_instance_init(CPUState *cs) From patchwork Wed Oct 18 16:37:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eFZzBt4J; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c5948pTz20Pd for ; Thu, 19 Oct 2023 03:39:41 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9YP-0000xh-O5; Wed, 18 Oct 2023 12:37:53 -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 1qt9YL-0000wc-7C for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:49 -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 1qt9YJ-0007O8-MZ for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mCBjqXciEfbUIqL0Z8mMxzxH/l5EMff3nfa5XLVTjNg=; b=eFZzBt4JwqnN/rtatNWQbwc0n2YrDp5zeNG48loEWqvbK1gzaz77OdyxocAEL2jNis6X6J TlpxuciMc9AJXzQYw/A6GBDewXeyZxb2JBOpJrSUToQKrwsZnOsMmoBcd5+CADL36dbv/C Skr8vBbnwYPdo8tQBmMtYcgINHhOJmM= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-422-9OcnfjbSM7-gK9WOFd72Jw-1; Wed, 18 Oct 2023 12:37:40 -0400 X-MC-Unique: 9OcnfjbSM7-gK9WOFd72Jw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9bea60bd1adso476196166b.0 for ; Wed, 18 Oct 2023 09:37:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647059; x=1698251859; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mCBjqXciEfbUIqL0Z8mMxzxH/l5EMff3nfa5XLVTjNg=; b=GT/Mkj5h9F5ZWBYjYWpuR1OyOPBEOEgKKUkHYOnR3CtsK4wveNgijI+IaBxIN+VS15 Y3CtgkPdySr2o+9EBwj/hXKUalaST/OXwyz/9B8IEsQHptbOy+30fserFPNfkodTwfmN dHP79x3WRQYfdF36G8uHEjc7Ck4Y1y+/XbgvZznitUtPh5JgyI4RkZrUcvHDdmB8lJt3 qH7ihL05rUjeYx/8qazQRAvmULmviFkRRDn7TrnzpHeA54C92GxGHrPdiQmoXrp1X5ke TzNHx2Uw/83vNdjsyDlbOTmi7biVU3Qy/M6Gh+/rNo2GQB4VBbZjfQeUFMTZgRmpdXth qQqg== X-Gm-Message-State: AOJu0YxL7u3kf38FkADnYF0FCVv0o/wYbyBPv+TCsxUf33SILIEBd7Vq IPRSwaE+VaTxeTLAdDY45RXLt0P6yBYJXjkH23/g16aXD8JJOhh7nAxE78rHzBVei0UoMiAl+/6 gVN2WyJ1YdqGbA4rZmM1XU0m7N8ILSBsOSKx9ponk5LuG2dhW3QSkEgmlzeV7TWEwSF5mSdFp/G s= X-Received: by 2002:a17:906:7311:b0:9a1:e0b1:e919 with SMTP id di17-20020a170906731100b009a1e0b1e919mr5029774ejc.4.1697647059089; Wed, 18 Oct 2023 09:37:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHh6SFbNshg7W+eZJ54cE+pODvDcYVgVD0sVVbRXrqAuZEJ9WBJpNJUC926xRncuTFGqsE0nA== X-Received: by 2002:a17:906:7311:b0:9a1:e0b1:e919 with SMTP id di17-20020a170906731100b009a1e0b1e919mr5029761ejc.4.1697647058710; Wed, 18 Oct 2023 09:37:38 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id t7-20020a1709066bc700b009b27d4153cfsm1990501ejs.176.2023.10.18.09.37.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 05/17] kvm: drop reference to KVM_CAP_PCI_2_3 Date: Wed, 18 Oct 2023 18:37:16 +0200 Message-ID: <20231018163728.363879-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is a remnant of pre-VFIO device assignment; it is not defined anymore by Linux and not used by QEMU. Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 7 ------- include/sysemu/kvm.h | 1 - include/sysemu/kvm_int.h | 1 - 3 files changed, 9 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index be50d47f7b4..50717a0d634 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2576,8 +2576,6 @@ static int kvm_init(MachineState *ms) s->max_nested_state_len = kvm_check_extension(s, KVM_CAP_NESTED_STATE); - s->intx_set_mask = kvm_check_extension(s, KVM_CAP_PCI_2_3); - s->irq_set_ioctl = KVM_IRQ_LINE; if (kvm_check_extension(s, KVM_CAP_IRQ_INJECT_STATUS)) { s->irq_set_ioctl = KVM_IRQ_LINE_STATUS; @@ -3237,11 +3235,6 @@ int kvm_has_gsi_routing(void) #endif } -int kvm_has_intx_set_mask(void) -{ - return kvm_state->intx_set_mask; -} - bool kvm_arm_supports_user_irq(void) { return kvm_check_extension(kvm_state, KVM_CAP_ARM_USER_IRQ); diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 575dee53b39..aa299396fba 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -215,7 +215,6 @@ int kvm_has_debugregs(void); int kvm_max_nested_state_length(void); int kvm_has_many_ioeventfds(void); int kvm_has_gsi_routing(void); -int kvm_has_intx_set_mask(void); /** * kvm_arm_supports_user_irq diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index a7dacd12d6c..817238b9582 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -85,7 +85,6 @@ struct KVMState #endif int max_nested_state_len; int many_ioeventfds; - int intx_set_mask; int kvm_shadow_mem; bool kernel_irqchip_allowed; bool kernel_irqchip_required; From patchwork Wed Oct 18 16:37:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RMCfCHuN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c723xj7z20cx for ; Thu, 19 Oct 2023 03:41:18 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9YL-0000we-H6; Wed, 18 Oct 2023 12:37:49 -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 1qt9YI-0000wB-Qt for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:47 -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 1qt9YH-0007Ni-3Z for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647063; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+b8spVZmCeWJIopjPtBaEljKehMV+lwxnBnfvcJB1w4=; b=RMCfCHuNX20CW0c399enFw3Zpc1fIwnITA7Cx017VrzBgeyAeNCuGs6BSu9g9qQPvlVwc/ xxm1i2vmmRtPZZCRyAb9HCPbZUq2vZUBur05u8g3+s1XqSBOHi8bloCOs5Fw6Uzicp6J4Y CH/rIGQSd9mrMuR7kKEOubH7B+Lzx2I= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-396-NMBjjvBZPLiu4v80khBILg-1; Wed, 18 Oct 2023 12:37:42 -0400 X-MC-Unique: NMBjjvBZPLiu4v80khBILg-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-53db360296eso5544391a12.3 for ; Wed, 18 Oct 2023 09:37:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647060; x=1698251860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+b8spVZmCeWJIopjPtBaEljKehMV+lwxnBnfvcJB1w4=; b=G5t2yL/efE7jOgC2PuBM6SLJCiiVTkx8V0eNUIhiFNKyzyVWBtL68zpH2kywPjI31Y VG4oo4nIMN0uv67bZLmQcyRBJPIB2UFn7NqZ3r8ryeeQEnYXuZtrW40JLwX3jmAA7/ix dLpy64RzbEIBR0obNeY95NqTZFlSbYtqcacB75lWRlWfxJj6l0Ne0mRkPWZlSrfgUZhl Yf3eTfx9e3zyuVBwzVofhFmdK04q+18bukqXJzwGv+1Sp+BynGhbPjoAmXUs+00mjumQ Ovfw0mv0XBPKeftn0izyElJiKjJVKal/CvvUSNlpsiVYG562EcTohULr3MovpPGsXiLG Eljw== X-Gm-Message-State: AOJu0Yzoq1iJBtDlLo/uR0BC/NYQSEbN/M/NaygyT5Q1alur846F/u2i 9Tb06RJXLc3nlkOtTyhhoB/GCBFAQgCqMHTFKjmn6lRl5OTWFRZ92VJ3FxRPir4K3AtWj8RdTQC peOWkhJTJN6RYwp7ZPBwUt0qZlXFHdBymA7SO8fSIySK461v/iU79U2d9XNHKkgLl5C1fWOcGkr A= X-Received: by 2002:a05:6402:2712:b0:53f:72a7:5ae with SMTP id y18-20020a056402271200b0053f72a705aemr1090887edd.12.1697647060681; Wed, 18 Oct 2023 09:37:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeOwt6LpscAh14wC4ySX7g1Oy8ihY7TC6wlm3NH8E4IwkLjEEJ06UFEdoWuQ1cjdFh2K+OrA== X-Received: by 2002:a05:6402:2712:b0:53f:72a7:5ae with SMTP id y18-20020a056402271200b0053f72a705aemr1090878edd.12.1697647060298; Wed, 18 Oct 2023 09:37:40 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id u27-20020a50a41b000000b0053dd798e38asm3108190edb.69.2023.10.18.09.37.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 06/17] kvm: assume that many ioeventfds can be created Date: Wed, 18 Oct 2023 18:37:17 +0200 Message-ID: <20231018163728.363879-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org NR_IOBUS_DEVS was increased to 200 in Linux 2.6.34. By Linux 3.5 it had increased to 1000 and later ioeventfds were changed to not count against the limit. But the earlier limit of 200 would already be enough for kvm_check_many_ioeventfds() to be true, so remove the check. Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 47 ---------------------------------------- accel/stubs/kvm-stub.c | 5 ----- hw/virtio/virtio-pci.c | 4 ---- include/sysemu/kvm.h | 1 - include/sysemu/kvm_int.h | 1 - 5 files changed, 58 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 50717a0d634..05be687be1b 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1253,43 +1253,6 @@ static int kvm_set_ioeventfd_pio(int fd, uint16_t addr, uint16_t val, } -static int kvm_check_many_ioeventfds(void) -{ - /* Userspace can use ioeventfd for io notification. This requires a host - * that supports eventfd(2) and an I/O thread; since eventfd does not - * support SIGIO it cannot interrupt the vcpu. - * - * Older kernels have a 6 device limit on the KVM io bus. Find out so we - * can avoid creating too many ioeventfds. - */ -#if defined(CONFIG_EVENTFD) - int ioeventfds[7]; - int i, ret = 0; - for (i = 0; i < ARRAY_SIZE(ioeventfds); i++) { - ioeventfds[i] = eventfd(0, EFD_CLOEXEC); - if (ioeventfds[i] < 0) { - break; - } - ret = kvm_set_ioeventfd_pio(ioeventfds[i], 0, i, true, 2, true); - if (ret < 0) { - close(ioeventfds[i]); - break; - } - } - - /* Decide whether many devices are supported or not */ - ret = i == ARRAY_SIZE(ioeventfds); - - while (i-- > 0) { - kvm_set_ioeventfd_pio(ioeventfds[i], 0, i, false, 2, true); - close(ioeventfds[i]); - } - return ret; -#else - return 0; -#endif -} - static const KVMCapabilityInfo * kvm_check_extension_list(KVMState *s, const KVMCapabilityInfo *list) { @@ -2648,8 +2611,6 @@ static int kvm_init(MachineState *ms) memory_listener_register(&kvm_coalesced_pio_listener, &address_space_io); - s->many_ioeventfds = kvm_check_many_ioeventfds(); - s->sync_mmu = !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU); if (!s->sync_mmu) { ret = ram_block_discard_disable(true); @@ -3218,14 +3179,6 @@ int kvm_max_nested_state_length(void) return kvm_state->max_nested_state_len; } -int kvm_has_many_ioeventfds(void) -{ - if (!kvm_enabled()) { - return 0; - } - return kvm_state->many_ioeventfds; -} - int kvm_has_gsi_routing(void) { #ifdef KVM_CAP_IRQ_ROUTING diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 19d58f2778f..b2d8885853f 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -40,11 +40,6 @@ bool kvm_has_sync_mmu(void) return false; } -int kvm_has_many_ioeventfds(void) -{ - return 0; -} - int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr) { return 1; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index abebd0075a6..a851c67bdd3 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2096,10 +2096,6 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) bool pcie_port = pci_bus_is_express(pci_get_bus(pci_dev)) && !pci_bus_is_root(pci_get_bus(pci_dev)); - if (kvm_enabled() && !kvm_has_many_ioeventfds()) { - proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD; - } - /* fd-based ioevents can't be synchronized in record/replay */ if (replay_mode != REPLAY_MODE_NONE) { proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD; diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index aa299396fba..15c427f6e09 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -213,7 +213,6 @@ int kvm_has_vcpu_events(void); int kvm_has_robust_singlestep(void); int kvm_has_debugregs(void); int kvm_max_nested_state_length(void); -int kvm_has_many_ioeventfds(void); int kvm_has_gsi_routing(void); /** diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 817238b9582..840b905a2e9 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -84,7 +84,6 @@ struct KVMState QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; #endif int max_nested_state_len; - int many_ioeventfds; int kvm_shadow_mem; bool kernel_irqchip_allowed; bool kernel_irqchip_required; From patchwork Wed Oct 18 16:37:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=chND4pXo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c700hSrz20cx for ; Thu, 19 Oct 2023 03:41:16 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9YT-0000zI-MP; Wed, 18 Oct 2023 12:37:59 -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 1qt9YN-0000xI-Sk for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:52 -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 1qt9YL-0007OG-9G for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647068; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3v4fziXI2JdunZbTarkocopBUuUnPczOIwhWDsrAqIg=; b=chND4pXoQ8pp2rmctcCC22zZlQkGlA9kEQGAMV9AT1P57QOaUXD9c0nvXQmVUELRLw3PPh D2jncQ2NKV6F4JlDXf2bvFJkL10NW1FldEDpL54FoRx67FtOyj2jhTekiIzeYycdTQaXnl zivSxHCro3n2K0zKyGoAafyJBccL0Nc= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-12-iYv8pM-qOn-j-UgD9uWgVw-1; Wed, 18 Oct 2023 12:37:45 -0400 X-MC-Unique: iYv8pM-qOn-j-UgD9uWgVw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9bd91ce3033so481919666b.0 for ; Wed, 18 Oct 2023 09:37:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647062; x=1698251862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3v4fziXI2JdunZbTarkocopBUuUnPczOIwhWDsrAqIg=; b=NH5JLmF2PU8NmR7n1XJyhN0fZ4dRnBwU4axk5QIyBFdZIegfnz2EgUAG/JqzhwOmb9 788pNtr3Aycxhwd4ocZsqZfNDw5sssECXymEEmU2RrTF8vYKJFqo+X/75s28Ah+2pK2j grhQ+XsnwS/mcgSzRLV1KV80jFIiu44mzZsQUQ/0UjpROBfgQhllTEVHUj+WbE4ldECh FwidnHVJDNm4qrpYwFX04r/1ouiN8CPVxIXtK9gNV0Om6ORIbbxHt5luq9Aqb0REV/7W NiBLYSMN5Bzg5xrhBpRRCt8g2JfurvM1bfVjsQcvt7wP1zuN3QDm+DPAJL4Vn4Ns6mHX xxSQ== X-Gm-Message-State: AOJu0YzkHmLccORZjv+gXXcg6y6oUu00OENgBH7a/N2eRvIqdEPNc4RW S/J4AyqKcB9tN59Uqwj4LBUjXTVG0Wq9UfZPqgFepFPhxiqrGoYnqPM2d2c0HpLOFuAlJbV25Qc aKv8HpkBufIcbGsdaTacCDZOsr4QzRiWPq+WiEbSw9c3JyDYsvm1JAe9qHjIYOW6hFfFLYCn3pn Y= X-Received: by 2002:a17:907:9407:b0:9a9:f2fd:2a2b with SMTP id dk7-20020a170907940700b009a9f2fd2a2bmr4052052ejc.73.1697647062395; Wed, 18 Oct 2023 09:37:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmFHWMV2CnH9CNpIQZ3Ni0P5oSr34AIv84RyMKI9s3gY6Q7+s0C/ux6NxaXjv1mHW8mjfo/w== X-Received: by 2002:a17:907:9407:b0:9a9:f2fd:2a2b with SMTP id dk7-20020a170907940700b009a9f2fd2a2bmr4052032ejc.73.1697647061904; Wed, 18 Oct 2023 09:37:41 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id lh22-20020a170906f8d600b009b94c545678sm1965453ejb.153.2023.10.18.09.37.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:41 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 07/17] kvm: require KVM_CAP_IOEVENTFD and KVM_CAP_IOEVENTFD_ANY_LENGTH Date: Wed, 18 Oct 2023 18:37:18 +0200 Message-ID: <20231018163728.363879-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org KVM_CAP_IOEVENTFD_ANY_LENGTH was added in Linux 4.4, released in 2016. Assume that it is present. Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 22 ++++++---------------- accel/stubs/kvm-stub.c | 2 -- hw/misc/pci-testdev.c | 3 +-- hw/s390x/virtio-ccw.c | 4 ---- hw/virtio/vhost-user.c | 7 +------ hw/virtio/virtio-mmio.c | 4 ---- hw/virtio/virtio-pci.c | 19 ++++--------------- include/sysemu/kvm.h | 19 ------------------- system/memory.c | 16 ++++++---------- 9 files changed, 18 insertions(+), 78 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 05be687be1b..120051da649 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -90,7 +90,6 @@ bool kvm_kernel_irqchip; bool kvm_split_irqchip; bool kvm_async_interrupts_allowed; bool kvm_halt_in_kernel_allowed; -bool kvm_eventfds_allowed; bool kvm_resamplefds_allowed; bool kvm_msi_via_irqfd_allowed; bool kvm_gsi_routing_allowed; @@ -98,7 +97,6 @@ bool kvm_gsi_direct_mapping; bool kvm_allowed; bool kvm_readonly_mem_allowed; bool kvm_vm_attributes_allowed; -bool kvm_ioeventfd_any_length_allowed; bool kvm_msi_use_devid; bool kvm_has_guest_debug; static int kvm_sstep_flags; @@ -110,6 +108,8 @@ static const KVMCapabilityInfo kvm_required_capabilites[] = { KVM_CAP_INFO(DESTROY_MEMORY_REGION_WORKS), KVM_CAP_INFO(JOIN_MEMORY_REGIONS_WORKS), KVM_CAP_INFO(INTERNAL_ERROR_DATA), + KVM_CAP_INFO(IOEVENTFD), + KVM_CAP_INFO(IOEVENTFD_ANY_LENGTH), KVM_CAP_LAST_INFO }; @@ -2547,18 +2547,12 @@ static int kvm_init(MachineState *ms) kvm_readonly_mem_allowed = (kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0); - kvm_eventfds_allowed = - (kvm_check_extension(s, KVM_CAP_IOEVENTFD) > 0); - kvm_resamplefds_allowed = (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0); kvm_vm_attributes_allowed = (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0); - kvm_ioeventfd_any_length_allowed = - (kvm_check_extension(s, KVM_CAP_IOEVENTFD_ANY_LENGTH) > 0); - #ifdef KVM_CAP_SET_GUEST_DEBUG kvm_has_guest_debug = (kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0); @@ -2595,19 +2589,15 @@ static int kvm_init(MachineState *ms) kvm_irqchip_create(s); } - if (kvm_eventfds_allowed) { - s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add; - s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del; - } + s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add; + s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del; s->memory_listener.listener.coalesced_io_add = kvm_coalesce_mmio_region; s->memory_listener.listener.coalesced_io_del = kvm_uncoalesce_mmio_region; kvm_memory_listener_register(s, &s->memory_listener, &address_space_memory, 0, "kvm-memory"); - if (kvm_eventfds_allowed) { - memory_listener_register(&kvm_io_listener, - &address_space_io); - } + memory_listener_register(&kvm_io_listener, + &address_space_io); memory_listener_register(&kvm_coalesced_pio_listener, &address_space_io); diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index b2d8885853f..1b37d9a302c 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -17,14 +17,12 @@ KVMState *kvm_state; bool kvm_kernel_irqchip; bool kvm_async_interrupts_allowed; -bool kvm_eventfds_allowed; bool kvm_resamplefds_allowed; bool kvm_msi_via_irqfd_allowed; bool kvm_gsi_routing_allowed; bool kvm_gsi_direct_mapping; bool kvm_allowed; bool kvm_readonly_mem_allowed; -bool kvm_ioeventfd_any_length_allowed; bool kvm_msi_use_devid; void kvm_flush_coalesced_mmio_buffer(void) diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c index 49303134e4c..acedd0f82bc 100644 --- a/hw/misc/pci-testdev.c +++ b/hw/misc/pci-testdev.c @@ -245,7 +245,6 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp) uint8_t *pci_conf; char *name; int r, i; - bool fastmmio = kvm_ioeventfd_any_length_enabled(); pci_conf = pci_dev->config; @@ -279,7 +278,7 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp) g_free(name); test->hdr->offset = cpu_to_le32(IOTEST_SIZE(i) + i * IOTEST_ACCESS_WIDTH); test->match_data = strcmp(IOTEST_TEST(i), "wildcard-eventfd"); - if (fastmmio && IOTEST_IS_MEM(i) && !test->match_data) { + if (IOTEST_IS_MEM(i) && !test->match_data) { test->size = 0; } else { test->size = IOTEST_ACCESS_WIDTH; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 17c548b84ff..80453718a33 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -768,10 +768,6 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp) sch->cssid, sch->ssid, sch->schid, sch->devno, ccw_dev->devno.valid ? "user-configured" : "auto-configured"); - if (kvm_enabled() && !kvm_eventfds_enabled()) { - dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD; - } - /* fd-based ioevents can't be synchronized in record/replay */ if (replay_mode != REPLAY_MODE_NONE) { dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD; diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 68eb1f0c99c..873d2b2eaae 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -264,11 +264,6 @@ struct scrub_regions { int fd_idx; }; -static bool ioeventfd_enabled(void) -{ - return !kvm_enabled() || kvm_eventfds_enabled(); -} - static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg) { struct vhost_user *u = dev->opaque; @@ -1218,7 +1213,7 @@ static int vhost_set_vring_file(struct vhost_dev *dev, .hdr.size = sizeof(msg.payload.u64), }; - if (ioeventfd_enabled() && file->fd > 0) { + if (file->fd > 0) { fds[fd_num++] = file->fd; } else { msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK; diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index c2c6d854750..22f15e1e02f 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -761,10 +761,6 @@ static void virtio_mmio_realizefn(DeviceState *d, Error **errp) qbus_init(&proxy->bus, sizeof(proxy->bus), TYPE_VIRTIO_MMIO_BUS, d, NULL); sysbus_init_irq(sbd, &proxy->irq); - if (!kvm_eventfds_enabled()) { - proxy->flags &= ~VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD; - } - /* fd-based ioevents can't be synchronized in record/replay */ if (replay_mode != REPLAY_MODE_NONE) { proxy->flags &= ~VIRTIO_IOMMIO_FLAG_USE_IOEVENTFD; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index a851c67bdd3..4af5e146c6a 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -332,7 +332,6 @@ static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier, VirtQueue *vq = virtio_get_queue(vdev, n); bool legacy = virtio_pci_legacy(proxy); bool modern = virtio_pci_modern(proxy); - bool fast_mmio = kvm_ioeventfd_any_length_enabled(); bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY; MemoryRegion *modern_mr = &proxy->notify.mr; MemoryRegion *modern_notify_mr = &proxy->notify_pio.mr; @@ -343,13 +342,8 @@ static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier, if (assign) { if (modern) { - if (fast_mmio) { - memory_region_add_eventfd(modern_mr, modern_addr, 0, - false, n, notifier); - } else { - memory_region_add_eventfd(modern_mr, modern_addr, 2, - false, n, notifier); - } + memory_region_add_eventfd(modern_mr, modern_addr, 0, + false, n, notifier); if (modern_pio) { memory_region_add_eventfd(modern_notify_mr, 0, 2, true, n, notifier); @@ -361,13 +355,8 @@ static int virtio_pci_ioeventfd_assign(DeviceState *d, EventNotifier *notifier, } } else { if (modern) { - if (fast_mmio) { - memory_region_del_eventfd(modern_mr, modern_addr, 0, - false, n, notifier); - } else { - memory_region_del_eventfd(modern_mr, modern_addr, 2, - false, n, notifier); - } + memory_region_del_eventfd(modern_mr, modern_addr, 0, + false, n, notifier); if (modern_pio) { memory_region_del_eventfd(modern_notify_mr, 0, 2, true, n, notifier); diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 15c427f6e09..c06982fd64c 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -36,13 +36,11 @@ extern bool kvm_kernel_irqchip; extern bool kvm_split_irqchip; extern bool kvm_async_interrupts_allowed; extern bool kvm_halt_in_kernel_allowed; -extern bool kvm_eventfds_allowed; extern bool kvm_resamplefds_allowed; extern bool kvm_msi_via_irqfd_allowed; extern bool kvm_gsi_routing_allowed; extern bool kvm_gsi_direct_mapping; extern bool kvm_readonly_mem_allowed; -extern bool kvm_ioeventfd_any_length_allowed; extern bool kvm_msi_use_devid; #define kvm_enabled() (kvm_allowed) @@ -86,15 +84,6 @@ extern bool kvm_msi_use_devid; */ #define kvm_halt_in_kernel() (kvm_halt_in_kernel_allowed) -/** - * kvm_eventfds_enabled: - * - * Returns: true if we can use eventfds to receive notifications - * from a KVM CPU (ie the kernel supports eventds and we are running - * with a configuration where it is meaningful to use them). - */ -#define kvm_eventfds_enabled() (kvm_eventfds_allowed) - /** * kvm_irqfds_enabled: * @@ -147,12 +136,6 @@ extern bool kvm_msi_use_devid; */ #define kvm_readonly_mem_enabled() (kvm_readonly_mem_allowed) -/** - * kvm_ioeventfd_any_length_enabled: - * Returns: true if KVM allows any length io eventfd. - */ -#define kvm_ioeventfd_any_length_enabled() (kvm_ioeventfd_any_length_allowed) - /** * kvm_msi_devid_required: * Returns: true if KVM requires a device id to be provided while @@ -167,13 +150,11 @@ extern bool kvm_msi_use_devid; #define kvm_irqchip_is_split() (false) #define kvm_async_interrupts_enabled() (false) #define kvm_halt_in_kernel() (false) -#define kvm_eventfds_enabled() (false) #define kvm_resamplefds_enabled() (false) #define kvm_msi_via_irqfd_enabled() (false) #define kvm_gsi_routing_allowed() (false) #define kvm_gsi_direct_mapping() (false) #define kvm_readonly_mem_enabled() (false) -#define kvm_ioeventfd_any_length_enabled() (false) #define kvm_msi_devid_required() (false) #endif /* CONFIG_KVM_IS_POSSIBLE */ diff --git a/system/memory.c b/system/memory.c index a800fbc9e59..4928f2525de 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1535,7 +1535,12 @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr, adjust_endianness(mr, &data, op); - if ((!kvm_eventfds_enabled()) && + /* + * FIXME: it's not clear why under KVM the write would be processed + * directly, instead of going through eventfd. This probably should + * test "tcg_enabled() || qtest_enabled()", or should just go away. + */ + if (!kvm_enabled() && memory_region_dispatch_write_eventfds(mr, addr, data, size, attrs)) { return MEMTX_OK; } @@ -2550,8 +2555,6 @@ void memory_region_clear_flush_coalesced(MemoryRegion *mr) } } -static bool userspace_eventfd_warning; - void memory_region_add_eventfd(MemoryRegion *mr, hwaddr addr, unsigned size, @@ -2568,13 +2571,6 @@ void memory_region_add_eventfd(MemoryRegion *mr, }; unsigned i; - if (kvm_enabled() && (!(kvm_eventfds_enabled() || - userspace_eventfd_warning))) { - userspace_eventfd_warning = true; - error_report("Using eventfd without MMIO binding in KVM. " - "Suboptimal performance expected"); - } - if (size) { adjust_endianness(mr, &mrfd.data, size_memop(size) | MO_TE); } From patchwork Wed Oct 18 16:37:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ARtg98/Z; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c756R0Kz23jS for ; Thu, 19 Oct 2023 03:41:21 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Ya-00019u-WC; Wed, 18 Oct 2023 12:38:05 -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 1qt9YP-0000y6-Px for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:53 -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 1qt9YN-0007OY-Tl for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647071; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9DXaOVU8n5+rY3kXTuZs/bw/xWaJBo8aerCJ6gbHW0o=; b=ARtg98/ZByKAnBA7VvPS3xF/LKmHmrU0NLN0zwXJRjvFPK46Z6JwGRtbtvZmoK581S1/4G qC2RF3CiF7t67UvwPWi1jEXknD6j1WIfFR0SnPh1GMPCWcgmst6dmBhZZ43yXBIWdMGaAk pNczuEsqUmHX7i7XqSLZtkaK3yilGn0= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-456-JPWNjAXRNvWwDA3DzetKig-1; Wed, 18 Oct 2023 12:37:49 -0400 X-MC-Unique: JPWNjAXRNvWwDA3DzetKig-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9bd86510329so513464966b.0 for ; Wed, 18 Oct 2023 09:37:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647068; x=1698251868; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9DXaOVU8n5+rY3kXTuZs/bw/xWaJBo8aerCJ6gbHW0o=; b=p/yGGEOEkMi94Rxb04xm5u3ItB0z69SbpPSau7XBwLLhzMmv8bI53JNva0J4WTyB/2 F+5EdX7XtvpyzvFf4XEXT+aYJphkTqc35yob7NeesVaylZC5n9/YE+pbB6r6l7YQUd93 yMUX1HboLeNeJq+FAe6EN7cBZd1JKEzlPHdsnf5d8jocSFgKG+QrSt92qphJgoIflzyL HKrpQXlrUJqEN+PePFMycaZdGp53HkHUawjfrjJxj7966+yPkEkAZUAaKG9atdN+THbU XPgnJ3SPqdyLPCsL4hoTOZxLi5OhOKKzJBNOv7PAJHfN9o/Q5s2bWZysbVdgu9FrN/Qf dR9A== X-Gm-Message-State: AOJu0YzDOv89C4S7niBIIqGtqBuz+hhSDARQPetHK0oNyB5E/jvDA5CR YVIyklCyi6dm65x5zhDc4zmpb7PuOUwau8x/Ls8HTAl0kEgWQTKbO9IGY5yRMfAF55GnLg39wtr AmMURPgw1kaCb+KDvN+i7/B6piA9PPaB9VTAoq/1xnohie0mWaHq5XnjCIWnBX7JnNzgtHGSPa8 E= X-Received: by 2002:a05:6402:1e91:b0:53f:6ee5:2cea with SMTP id f17-20020a0564021e9100b0053f6ee52ceamr1524623edf.17.1697647068113; Wed, 18 Oct 2023 09:37:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE4Er/dZiguoGJamqvqe0Vgr9zQ0V1LEctiEvvcs757WW6KQmFCyLcWQa5uL4zGarZ7mtxHXw== X-Received: by 2002:a05:6402:1e91:b0:53f:6ee5:2cea with SMTP id f17-20020a0564021e9100b0053f6ee52ceamr1524610edf.17.1697647067874; Wed, 18 Oct 2023 09:37:47 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id s10-20020a508dca000000b005340d9d042bsm3000959edh.40.2023.10.18.09.37.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 08/17] kvm: unify listeners for PIO address space Date: Wed, 18 Oct 2023 18:37:19 +0200 Message-ID: <20231018163728.363879-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Since we now assume that ioeventfds are present, kvm_io_listener is always registered. Merge it with kvm_coalesced_pio_listener in a single listener. Since PIO space does not have KVM memslots attached to it, the priority is irrelevant. Signed-off-by: Paolo Bonzini Reviewed-by: Manos Pitsidianakis --- accel/kvm/kvm-all.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 120051da649..b59a48da924 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1105,13 +1105,6 @@ static void kvm_coalesce_pio_del(MemoryListener *listener, } } -static MemoryListener kvm_coalesced_pio_listener = { - .name = "kvm-coalesced-pio", - .coalesced_io_add = kvm_coalesce_pio_add, - .coalesced_io_del = kvm_coalesce_pio_del, - .priority = MEMORY_LISTENER_PRIORITY_MIN, -}; - int kvm_check_extension(KVMState *s, unsigned int extension) { int ret; @@ -1768,6 +1761,8 @@ void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, static MemoryListener kvm_io_listener = { .name = "kvm-io", + .coalesced_io_add = kvm_coalesce_pio_add, + .coalesced_io_del = kvm_coalesce_pio_del, .eventfd_add = kvm_io_ioeventfd_add, .eventfd_del = kvm_io_ioeventfd_del, .priority = MEMORY_LISTENER_PRIORITY_DEV_BACKEND, @@ -2598,8 +2593,6 @@ static int kvm_init(MachineState *ms) &address_space_memory, 0, "kvm-memory"); memory_listener_register(&kvm_io_listener, &address_space_io); - memory_listener_register(&kvm_coalesced_pio_listener, - &address_space_io); s->sync_mmu = !!kvm_vm_check_extension(kvm_state, KVM_CAP_SYNC_MMU); if (!s->sync_mmu) { From patchwork Wed Oct 18 16:37:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZK0silyp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c3z59Jcz20Pd for ; Thu, 19 Oct 2023 03:38:39 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Yb-0001BQ-9r; Wed, 18 Oct 2023 12:38:05 -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 1qt9YR-0000ya-Df for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:55 -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 1qt9YP-0007Oo-Hf for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647072; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p3CNP1QuoS1paUivlb9aVuEK/Faji/cYsHMDMufGa0o=; b=ZK0silyprKEObEtlEH4dOBW681emjY3MVYjDfSqKF4nZi706323pANkPgEafBgE6Ql23zi I7+E24IBvjCgubKYnS9fU2po0EicnTJF4Qnr8x4rdcibDmYY4MTKNwyc4GOvKtvUAlJvEz Qh5tTSZ0bmARXCcD4kWpmIwbSkDngCI= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-110-r6QbReZkMjGnFrRwGyKWgQ-1; Wed, 18 Oct 2023 12:37:51 -0400 X-MC-Unique: r6QbReZkMjGnFrRwGyKWgQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9c6a4a60033so114827666b.1 for ; Wed, 18 Oct 2023 09:37:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647070; x=1698251870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p3CNP1QuoS1paUivlb9aVuEK/Faji/cYsHMDMufGa0o=; b=CvdoIGBsmQjL0MbuC3FgBrNLdPokrLqIZsnO46rab35GlSNKJj9aWXNPlRPBRp+fgu Hgya50EFpcjtPHB+1SVXuvir26DGF2VPK+0gp7J5uHE6JLt0nWs6s1/gMs6KPXfJvQiO fYeO+FYoAzKDME4ucnT5lXXwpLsg+ZL9LDz2N8cj+6gemgGXrVQk2HRwbyA1/CZ5MdOL zScEomBpdm+dgv+bJacdrWySm0Fcb9hiBLX1DyoYj4z8CBCGHLq2nSZrTMNDQmontrgm +OC+NwW3kgKIdQbqV9MrygoBRkXIkzkZtpnTQkvi393s/7VZHs0U6nAAYiZ7vPPk8rqT ueRQ== X-Gm-Message-State: AOJu0YyVkKDWp31ueOvBp+0lkQjYn6Zf4I9dS7BJ2nAyl0C5jDjnHyf1 ajAE4gNHysY9AIx6cA/JtadSLy+4fRltu+5bHYHD1GaBzcXvjvielOYyn/QGEw8zeve01QDs0SI ++Ajf7xAjWF0QDLahgs4ZCUiDLizPOQdYwwRrtCKo1KwhJbY5pU0bfFbdxaJBYWkPwBh+FfPHoV o= X-Received: by 2002:a17:907:368b:b0:9c1:edd8:43c2 with SMTP id bi11-20020a170907368b00b009c1edd843c2mr4846629ejc.42.1697647069761; Wed, 18 Oct 2023 09:37:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9uh9H7EB9Nv6fksFBmGVg1ro56qtklZyjY1qH1MnxQ7MZ7a14HnK9SqC6+lLKCkkxnv7I/Q== X-Received: by 2002:a17:907:368b:b0:9c1:edd8:43c2 with SMTP id bi11-20020a170907368b00b009c1edd843c2mr4846610ejc.42.1697647069334; Wed, 18 Oct 2023 09:37:49 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id v15-20020a17090651cf00b009ae482d70besm1990438ejk.134.2023.10.18.09.37.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:48 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 09/17] kvm: arm: require KVM_CAP_SET_VCPU_EVENTS Date: Wed, 18 Oct 2023 18:37:20 +0200 Message-ID: <20231018163728.363879-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org KVM_CAP_SET_VCPU_EVENTS was added in Linux 4.19, released in 2018. It was backported to RHEL8's 4.18 kernel and is in other supported distros as well. While it is nice that QEMU can run even on older kernels, for example on boards that can only run old vendor kernels, I don't think this should extend to ancient versions of KVM/ARM which, at the time, was still moving pretty fast. As a reference, 4.19 still had 32-bit KVM support. Signed-off-by: Paolo Bonzini --- target/arm/kvm.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/target/arm/kvm.c b/target/arm/kvm.c index b66b936a958..a50e975181f 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -34,6 +34,7 @@ #include "qemu/log.h" const KVMCapabilityInfo kvm_arch_required_capabilities[] = { + KVM_CAP_INFO(VCPU_EVENTS), KVM_CAP_LAST_INFO }; @@ -756,10 +757,6 @@ int kvm_put_vcpu_events(ARMCPU *cpu) struct kvm_vcpu_events events; int ret; - if (!kvm_has_vcpu_events()) { - return 0; - } - memset(&events, 0, sizeof(events)); events.exception.serror_pending = env->serror.pending; @@ -785,10 +782,6 @@ int kvm_get_vcpu_events(ARMCPU *cpu) struct kvm_vcpu_events events; int ret; - if (!kvm_has_vcpu_events()) { - return 0; - } - memset(&events, 0, sizeof(events)); ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_VCPU_EVENTS, &events); if (ret) { @@ -927,7 +920,6 @@ static int kvm_arm_handle_dabt_nisv(CPUState *cs, uint64_t esr_iss, * synchronization can be exceptionally skipped. */ events.exception.ext_dabt_pending = 1; - /* KVM_CAP_ARM_INJECT_EXT_DABT implies KVM_CAP_VCPU_EVENTS */ if (!kvm_vcpu_ioctl(cs, KVM_SET_VCPU_EVENTS, &events)) { env->ext_dabt_raised = 1; return 0; From patchwork Wed Oct 18 16:37:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LGHr5VA/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c7p0JW6z20cx for ; Thu, 19 Oct 2023 03:41:58 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Yf-0001Io-5Z; Wed, 18 Oct 2023 12:38:09 -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 1qt9YX-00015v-NS for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:03 -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 1qt9YW-0007PO-85 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+hNy/PELxO0LF0vJtqdJo5ueuCedDBfVu0vtDyuyZxs=; b=LGHr5VA/NXYTZBw7P5WuPH+o4DaGt6UJ7WWhND0nnfntO9sgrVDUYEBKVDHjYBOy18cdlk 5ofkMTUaMaCtP6Hom73yWSOZWozQRahX1uIKeQxU2tSUEOVotFUKgdnc33VnTZOffVbLQ8 vKpjj5b2RN8ZKAvWYQ71c88LXGM2zE8= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-1sUdqgXrPS2LaUWDI_oKBA-1; Wed, 18 Oct 2023 12:37:52 -0400 X-MC-Unique: 1sUdqgXrPS2LaUWDI_oKBA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9bf8678af70so305756366b.2 for ; Wed, 18 Oct 2023 09:37:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647071; x=1698251871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+hNy/PELxO0LF0vJtqdJo5ueuCedDBfVu0vtDyuyZxs=; b=tX4BjerR7ndVGdMCH5dehlfph5veFPhIxS+7kBdw0n6KR7Hroj/OQYPrHO9okwlny5 e7zdcUQkvJ8LU2QfPD2WQDvGPknMClG5G6Aec5LQfDI7EhTKQXLiXtKz46M7JbSkvxzj Lf+SVtY1ewUJnGdUFiA27dVtTP224v7W2nQCmhDw5iyiJYvhFpfaod4dxU99dSMBHpQw wRKzW2DyKT9jKqamtZFk1zko6MOOMIJNhtvVmSo7a8IL56QhL5WZAmfB0KTQivlkqXCH imlPr9KOYefI/IhI5t4CpZJSJDlugO2phKpNiyTfspclwtZp4qdnC+P05GoG5eYA6Yef 5XpQ== X-Gm-Message-State: AOJu0YxkRVzR3rXsO8w+dz0ostEBRaHoQLLAT4ZUgAujK7hHPNoi9x6H Zk5Lep6W0gouXaMTUyngjK++lfMXLmFGpUuC1qjGZy8MrW1c99jXnzq8NSXhUPLvDuEvQ204X8G apFacr64V0+lg49Hhq8Nv4G2kZgdJcmoNgtC+1FFa06G2b77/w4Ox+fj3EWIwAvfRDfI/e5wzux E= X-Received: by 2002:a17:907:3e99:b0:9bd:c336:21e5 with SMTP id hs25-20020a1709073e9900b009bdc33621e5mr4173832ejc.56.1697647071342; Wed, 18 Oct 2023 09:37:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkNmKEi8Qn3S+jHyt7bhLOBEdNAXJB0tM3ofBpQaSvsmAx3oK1UQxbbQfcZWhKDVrleHa0Uw== X-Received: by 2002:a17:907:3e99:b0:9bd:c336:21e5 with SMTP id hs25-20020a1709073e9900b009bdc33621e5mr4173817ejc.56.1697647070924; Wed, 18 Oct 2023 09:37:50 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id u7-20020a1709060b0700b009b64987e1absm1982707ejg.139.2023.10.18.09.37.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 10/17] kvm: i386: move KVM_CAP_IRQ_ROUTING detection to kvm_arch_required_capabilities Date: Wed, 18 Oct 2023 18:37:21 +0200 Message-ID: <20231018163728.363879-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Simple code cleanup. Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index ab7d39d5399..91dd43eaa9b 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -92,6 +92,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_INFO(EXT_CPUID), KVM_CAP_INFO(MP_STATE), KVM_CAP_INFO(SIGNAL_MSI), + KVM_CAP_INFO(IRQ_ROUTING), KVM_CAP_LAST_INFO }; @@ -2590,11 +2591,6 @@ int kvm_arch_init(MachineState *ms, KVMState *s) return ret; } - if (!kvm_check_extension(s, KVM_CAP_IRQ_ROUTING)) { - error_report("kvm: KVM_CAP_IRQ_ROUTING not supported by KVM"); - return -ENOTSUP; - } - has_xsave = kvm_check_extension(s, KVM_CAP_XSAVE); has_xcrs = kvm_check_extension(s, KVM_CAP_XCRS); has_pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2); From patchwork Wed Oct 18 16:37:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851048 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZuqeB/lA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c4d4Q6wz20Pd for ; Thu, 19 Oct 2023 03:39:13 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Z5-0001m0-SB; Wed, 18 Oct 2023 12:38:35 -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 1qt9Yj-0001OY-Sy for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:15 -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 1qt9Yi-0007QG-Eg for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=duiHUT8st5eyEW1wOxW61bUKxv0U4vv/DGWXwswcz+Y=; b=ZuqeB/lAD43N8nqeIYjjW/AGloHTu3+KQi5IB5LHnK9PUzHXWG6eHTcEODYLb+6o1EkvEy 8ePwmzT4pTVoVjUCWcCloaxwbt4c5Aa3IQwP7wDp3NZMCRtvVPtAIyU0zrZ4PpfScBaSAB fFh9FJgLFmadOBP83RoGNu2Eyhyr80k= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-hXoO9FBZPnG6eAAH5uppjw-1; Wed, 18 Oct 2023 12:37:54 -0400 X-MC-Unique: hXoO9FBZPnG6eAAH5uppjw-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-993eeb3a950so471041166b.2 for ; Wed, 18 Oct 2023 09:37:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647073; x=1698251873; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=duiHUT8st5eyEW1wOxW61bUKxv0U4vv/DGWXwswcz+Y=; b=ObVsuHWI6LzVljuWmOT37XEsiqA+gODjrhUF4B9fLRmHY0Xu1JNXzqfewCetggyn0L aXJKBS3oOlAKG+KyAu36VFuqIqLSERGM9CNBFuCe1zRo4PgE712D/HZGYjnlxL7hjJ7K HGxfcnhtJIfz6jZXyAuQNiuILsYTTWsC/8/Zn2I4D2migsAH/iT1HEVItQqjtEJc3uKl txh9LzsBWPdqVcdRDghiZps4V7sABJogv9w2U/KPH/nx5bPJNjSAyYYT1IW7Be2Mr2GR 4eb1L4swdpCKheb2FEdhz/fLq3Yk3WokzXzbT6TOrn47PsHhJQb2OrDNyheK5fOSi6s+ A1SQ== X-Gm-Message-State: AOJu0YwOR2aArq5v53C02DNNrKDhAoG3yUQFpT+gHS+bFECd5YGTXfcB 7htHU2LJMyc/NDizo+ITG3yVBQnipoBnsD+WezqmALSr4gzS4BNhGMRLfJ8L85fD9EhiqK7aDkC NtDQ+WYtdT1cgKDmn4NHWQz0Aq44Yz1d50lcciY/T9BFjnbIbMWu/o1MhLWtoF5LDTJ2o6d+wnj M= X-Received: by 2002:a17:906:ee86:b0:9be:cdca:dae9 with SMTP id wt6-20020a170906ee8600b009becdcadae9mr4589168ejb.36.1697647072919; Wed, 18 Oct 2023 09:37:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEV1tOGmBtg6EPRNfybbGe8bXWdinz3Zno8piiSpInItRhmqoeLYg47+FGFneRKOK6IZTXw8g== X-Received: by 2002:a17:906:ee86:b0:9be:cdca:dae9 with SMTP id wt6-20020a170906ee8600b009becdcadae9mr4589150ejb.36.1697647072474; Wed, 18 Oct 2023 09:37:52 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id z9-20020a1709063a0900b009c758b6cdefsm261859eje.128.2023.10.18.09.37.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:51 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 11/17] kvm: i386: require KVM_CAP_DEBUGREGS Date: Wed, 18 Oct 2023 18:37:22 +0200 Message-ID: <20231018163728.363879-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This was introduced in KVM in Linux 2.6.35, we can require it unconditionally. Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 9 --------- include/sysemu/kvm.h | 1 - include/sysemu/kvm_int.h | 1 - target/i386/kvm/kvm.c | 9 +-------- 4 files changed, 1 insertion(+), 19 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b59a48da924..aeda902b3e9 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2528,10 +2528,6 @@ static int kvm_init(MachineState *ms) s->robust_singlestep = kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP); -#ifdef KVM_CAP_DEBUGREGS - s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS); -#endif - s->max_nested_state_len = kvm_check_extension(s, KVM_CAP_NESTED_STATE); s->irq_set_ioctl = KVM_IRQ_LINE; @@ -3152,11 +3148,6 @@ int kvm_has_robust_singlestep(void) return kvm_state->robust_singlestep; } -int kvm_has_debugregs(void) -{ - return kvm_state->debugregs; -} - int kvm_max_nested_state_length(void) { return kvm_state->max_nested_state_len; diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index c06982fd64c..16fddeef663 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -192,7 +192,6 @@ unsigned int kvm_get_free_memslots(void); bool kvm_has_sync_mmu(void); int kvm_has_vcpu_events(void); int kvm_has_robust_singlestep(void); -int kvm_has_debugregs(void); int kvm_max_nested_state_length(void); int kvm_has_gsi_routing(void); diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 840b905a2e9..151ecc84233 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -79,7 +79,6 @@ struct KVMState bool coalesced_flush_in_progress; int vcpu_events; int robust_singlestep; - int debugregs; #ifdef KVM_CAP_SET_GUEST_DEBUG QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; #endif diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 91dd43eaa9b..86af39c437a 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -93,6 +93,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_INFO(MP_STATE), KVM_CAP_INFO(SIGNAL_MSI), KVM_CAP_INFO(IRQ_ROUTING), + KVM_CAP_INFO(DEBUGREGS), KVM_CAP_LAST_INFO }; @@ -4601,10 +4602,6 @@ static int kvm_put_debugregs(X86CPU *cpu) struct kvm_debugregs dbgregs; int i; - if (!kvm_has_debugregs()) { - return 0; - } - memset(&dbgregs, 0, sizeof(dbgregs)); for (i = 0; i < 4; i++) { dbgregs.db[i] = env->dr[i]; @@ -4622,10 +4619,6 @@ static int kvm_get_debugregs(X86CPU *cpu) struct kvm_debugregs dbgregs; int i, ret; - if (!kvm_has_debugregs()) { - return 0; - } - ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_DEBUGREGS, &dbgregs); if (ret < 0) { return ret; From patchwork Wed Oct 18 16:37:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cclnuuwk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c3y61xbz23kM for ; Thu, 19 Oct 2023 03:38:38 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Ye-0001EH-5T; Wed, 18 Oct 2023 12:38:08 -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 1qt9YW-00015m-Ff for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt9YU-0007PD-4I for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:37:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CveuO4yQ9evvGjnDfztuEGseRr4CnPjVKEaq7EdVTys=; b=cclnuuwkiuVSraWYH+hCWvmXD2/ZcHoqVraYp/N2N2bIjf8dJUo3xGCU4DO/ISA/n43KgD x9lARs8EpYgvAP8P1Y0Qj2h6vwrUMVHO2sk4/dbegV5Nu9quv53JvQm74bpjb/vdbR0w3O 7Re/YCnyUbBbVHEL90m7vnELp4vplmI= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-3-Y48A-eGMPeqi4Ok4B61DDQ-1; Wed, 18 Oct 2023 12:37:56 -0400 X-MC-Unique: Y48A-eGMPeqi4Ok4B61DDQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9ae686dafedso516437466b.3 for ; Wed, 18 Oct 2023 09:37:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647074; x=1698251874; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CveuO4yQ9evvGjnDfztuEGseRr4CnPjVKEaq7EdVTys=; b=T6YA8ddOrfa8iTHMppxLQD/am/DFsKDjvd3ZqJ5pFyQVrft5HalytDO1CyT5P6jtVL 54Od0ft/ahy/SBq3KImyaxSMZpSOtuxnSN9FfX0ilJe6EIUSZV/XQzHWqzBO3ndJv7KH A41ouWmd7Iow5rxhOhieXwm8z93OmpAKgoeiVaoZ4zNcvbz9I8qQOYAiGRcRb/w3qheJ l9p8EVFmdUo0JISTEY0+zi00uu0bvry8odQmurbPwJ8gcN+ZWLHb59nr7lNlShOF6Rc5 /gypzEP35wr8i9q3CO++jlAfUmVmrgjTKw5oaE5jFlkL0PsS/C3a60rSyhRag0JHzDmf +ThA== X-Gm-Message-State: AOJu0YynrkJk+fenRapCaPPO6lqGgOURGAEfeH8Nu6sXNny+Ao9tYAOe No9fYHJ+J/3YH0Vsn4nj5rpqgjqgaHnxqj+vyJrOex3dSJBpdSaD+G06oThPljdOW6oOxIiO6Dv V9Ef8Z4SO4pfysPxZC20aglC96vd29zRdVx7Etv8SjQ9BISW/9chDwa/843DEs/VCSp6HkTFtSm o= X-Received: by 2002:a17:907:2ce2:b0:9b2:a7db:9662 with SMTP id hz2-20020a1709072ce200b009b2a7db9662mr4334449ejc.12.1697647074446; Wed, 18 Oct 2023 09:37:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7HyIjRgKM3PmSVghq70NMlO0Oe9R6ZMDbbUhTQ+R2RhN4ZmjN9jtrHsczkIMTMjflgZLApw== X-Received: by 2002:a17:907:2ce2:b0:9b2:a7db:9662 with SMTP id hz2-20020a1709072ce200b009b2a7db9662mr4334434ejc.12.1697647074056; Wed, 18 Oct 2023 09:37:54 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id q27-20020a1709066b1b00b0099b8234a9fesm2027804ejr.1.2023.10.18.09.37.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 12/17] kvm: i386: require KVM_CAP_XSAVE Date: Wed, 18 Oct 2023 18:37:23 +0200 Message-ID: <20231018163728.363879-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.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.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This was introduced in KVM in Linux 2.6.36, and could already be used at the time to save/restore FPU data even on older processor. We can require it unconditionally and stop using KVM_GET/SET_FPU. Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 70 ++----------------------------------------- 1 file changed, 2 insertions(+), 68 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 86af39c437a..f6622684024 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -94,6 +94,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_INFO(SIGNAL_MSI), KVM_CAP_INFO(IRQ_ROUTING), KVM_CAP_INFO(DEBUGREGS), + KVM_CAP_INFO(XSAVE), KVM_CAP_LAST_INFO }; @@ -137,7 +138,6 @@ static uint32_t has_architectural_pmu_version; static uint32_t num_architectural_pmu_gp_counters; static uint32_t num_architectural_pmu_fixed_counters; -static int has_xsave; static int has_xsave2; static int has_xcrs; static int has_pit_state2; @@ -1714,10 +1714,8 @@ static void kvm_init_xsave(CPUX86State *env) { if (has_xsave2) { env->xsave_buf_len = QEMU_ALIGN_UP(has_xsave2, 4096); - } else if (has_xsave) { - env->xsave_buf_len = sizeof(struct kvm_xsave); } else { - return; + env->xsave_buf_len = sizeof(struct kvm_xsave); } env->xsave_buf = qemu_memalign(4096, env->xsave_buf_len); @@ -2592,7 +2590,6 @@ int kvm_arch_init(MachineState *ms, KVMState *s) return ret; } - has_xsave = kvm_check_extension(s, KVM_CAP_XSAVE); has_xcrs = kvm_check_extension(s, KVM_CAP_XCRS); has_pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2); has_sregs2 = kvm_check_extension(s, KVM_CAP_SREGS2) > 0; @@ -2877,40 +2874,11 @@ static int kvm_getput_regs(X86CPU *cpu, int set) return ret; } -static int kvm_put_fpu(X86CPU *cpu) -{ - CPUX86State *env = &cpu->env; - struct kvm_fpu fpu; - int i; - - memset(&fpu, 0, sizeof fpu); - fpu.fsw = env->fpus & ~(7 << 11); - fpu.fsw |= (env->fpstt & 7) << 11; - fpu.fcw = env->fpuc; - fpu.last_opcode = env->fpop; - fpu.last_ip = env->fpip; - fpu.last_dp = env->fpdp; - for (i = 0; i < 8; ++i) { - fpu.ftwx |= (!env->fptags[i]) << i; - } - memcpy(fpu.fpr, env->fpregs, sizeof env->fpregs); - for (i = 0; i < CPU_NB_REGS; i++) { - stq_p(&fpu.xmm[i][0], env->xmm_regs[i].ZMM_Q(0)); - stq_p(&fpu.xmm[i][8], env->xmm_regs[i].ZMM_Q(1)); - } - fpu.mxcsr = env->mxcsr; - - return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_FPU, &fpu); -} - static int kvm_put_xsave(X86CPU *cpu) { CPUX86State *env = &cpu->env; void *xsave = env->xsave_buf; - if (!has_xsave) { - return kvm_put_fpu(cpu); - } x86_cpu_xsave_all_areas(cpu, xsave, env->xsave_buf_len); return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_XSAVE, xsave); @@ -3655,46 +3623,12 @@ static int kvm_put_msrs(X86CPU *cpu, int level) } -static int kvm_get_fpu(X86CPU *cpu) -{ - CPUX86State *env = &cpu->env; - struct kvm_fpu fpu; - int i, ret; - - ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_FPU, &fpu); - if (ret < 0) { - return ret; - } - - env->fpstt = (fpu.fsw >> 11) & 7; - env->fpus = fpu.fsw; - env->fpuc = fpu.fcw; - env->fpop = fpu.last_opcode; - env->fpip = fpu.last_ip; - env->fpdp = fpu.last_dp; - for (i = 0; i < 8; ++i) { - env->fptags[i] = !((fpu.ftwx >> i) & 1); - } - memcpy(env->fpregs, fpu.fpr, sizeof env->fpregs); - for (i = 0; i < CPU_NB_REGS; i++) { - env->xmm_regs[i].ZMM_Q(0) = ldq_p(&fpu.xmm[i][0]); - env->xmm_regs[i].ZMM_Q(1) = ldq_p(&fpu.xmm[i][8]); - } - env->mxcsr = fpu.mxcsr; - - return 0; -} - static int kvm_get_xsave(X86CPU *cpu) { CPUX86State *env = &cpu->env; void *xsave = env->xsave_buf; int type, ret; - if (!has_xsave) { - return kvm_get_fpu(cpu); - } - type = has_xsave2 ? KVM_GET_XSAVE2 : KVM_GET_XSAVE; ret = kvm_vcpu_ioctl(CPU(cpu), type, xsave); if (ret < 0) { From patchwork Wed Oct 18 16:37:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=io8kl2VY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c756Pz7z20cx for ; Thu, 19 Oct 2023 03:41:21 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Yf-0001Lp-Nv; Wed, 18 Oct 2023 12:38:09 -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 1qt9YY-00015w-2G for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:03 -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 1qt9YW-0007PK-6A for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647079; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZwBXfwtovplKeapXMtU28sMweVSX1aOJBcTWkR2PNQA=; b=io8kl2VY3yyNH4cUfwnEgAsiK1Q7+VKb0YPP0vGEbbptdC3t1h+rm3JSpyc/7BadWL+oeq b+oE+uveSBtE+QIa3IA4OBgsc1M9l5jnYfAKtvIUzWLCJFtmjxNAO4le7bCbiMs3goDbne WG9XcxpQeIXAzyWm3WiAR9EyswwJXGo= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-nWWKdYpoNvuhafBauTrLgA-1; Wed, 18 Oct 2023 12:37:57 -0400 X-MC-Unique: nWWKdYpoNvuhafBauTrLgA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-53dfe3af1b9so5473194a12.1 for ; Wed, 18 Oct 2023 09:37:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647076; x=1698251876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZwBXfwtovplKeapXMtU28sMweVSX1aOJBcTWkR2PNQA=; b=RDChvdijOwVYMQ+RTTWN8L4I6fNG1KiPxnhT270x3oFsrdswrl/eYQ5XZRkeD6RtYh X9uyHPFfl8pj1hbRG3Wb4/rG0XNUtzSSkk7+D1s2BO9ZcFIY2yal/hvjqiJMuswMqHpT 5bUcVlAX/VXPdPH3jj3Fpgx83EYMIYScY6TqG9DCrkflZU9uPfV/zz6FAXVrI7hu+z9l kI/GDTGNQHSTOCqsJmGh/BJL6Do7loJj1RMHIZw7pC4xzyVUIb/ljPOuCDKCqcnNmAxo Ugnusvp2Wh+E1I3wsESFuLXaD+xGbpneiEYmYleXQQRH1FLckQ5ACrjqtisDh9SL+maD eUzw== X-Gm-Message-State: AOJu0YzqSYqB1w0/yEOM9+AO1jzg3rf47WuU4jR7uLbi5sORwNIxTgN8 /G8uD6FzTtiLutdwSNIzM9HOtd84BUc+VXJjY8eGifCFB/UbTSRJiXC2aKVi2/Xs8V3w/932OW2 hB8AIVobhmsoJNHQ5eDwkhaqIIEyw4sbOiGWXB+YKZPrDNlsd6BRdDv1xWC33Y83ZGVMZhorsXj 4= X-Received: by 2002:a17:906:fd54:b0:9c7:4e5d:129a with SMTP id wi20-20020a170906fd5400b009c74e5d129amr1229708ejb.53.1697647076052; Wed, 18 Oct 2023 09:37:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHe5Gu1z61XwVfqOaYViBaRw+DK7pacPyWzHEWvRo7P+tcn05t5iL4awzf6vjqW9u1LcBnLow== X-Received: by 2002:a17:906:fd54:b0:9c7:4e5d:129a with SMTP id wi20-20020a170906fd5400b009c74e5d129amr1229698ejb.53.1697647075720; Wed, 18 Oct 2023 09:37:55 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id oz4-20020a170906cd0400b009c751e41ebasm1244561ejb.141.2023.10.18.09.37.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 13/17] kvm: i386: require KVM_CAP_SET_VCPU_EVENTS and KVM_CAP_X86_ROBUST_SINGLESTEP Date: Wed, 18 Oct 2023 18:37:24 +0200 Message-ID: <20231018163728.363879-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 12 ------ include/sysemu/kvm.h | 2 - include/sysemu/kvm_int.h | 2 - target/i386/kvm/kvm.c | 92 +--------------------------------------- 4 files changed, 2 insertions(+), 106 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index aeda902b3e9..608da41465d 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2521,13 +2521,6 @@ static int kvm_init(MachineState *ms) } } -#ifdef KVM_CAP_VCPU_EVENTS - s->vcpu_events = kvm_check_extension(s, KVM_CAP_VCPU_EVENTS); -#endif - - s->robust_singlestep = - kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP); - s->max_nested_state_len = kvm_check_extension(s, KVM_CAP_NESTED_STATE); s->irq_set_ioctl = KVM_IRQ_LINE; @@ -3138,11 +3131,6 @@ bool kvm_has_sync_mmu(void) return kvm_state->sync_mmu; } -int kvm_has_vcpu_events(void) -{ - return kvm_state->vcpu_events; -} - int kvm_has_robust_singlestep(void) { return kvm_state->robust_singlestep; diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 16fddeef663..a2526009c6c 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -190,8 +190,6 @@ typedef struct KVMRouteChange { unsigned int kvm_get_max_memslots(void); unsigned int kvm_get_free_memslots(void); bool kvm_has_sync_mmu(void); -int kvm_has_vcpu_events(void); -int kvm_has_robust_singlestep(void); int kvm_max_nested_state_length(void); int kvm_has_gsi_routing(void); diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h index 151ecc84233..2dd684a363c 100644 --- a/include/sysemu/kvm_int.h +++ b/include/sysemu/kvm_int.h @@ -77,8 +77,6 @@ struct KVMState int coalesced_pio; struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; bool coalesced_flush_in_progress; - int vcpu_events; - int robust_singlestep; #ifdef KVM_CAP_SET_GUEST_DEBUG QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; #endif diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index f6622684024..5db3fd0f4c4 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -95,6 +95,8 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_INFO(IRQ_ROUTING), KVM_CAP_INFO(DEBUGREGS), KVM_CAP_INFO(XSAVE), + KVM_CAP_INFO(VCPU_EVENTS), + KVM_CAP_INFO(X86_ROBUST_SINGLESTEP), KVM_CAP_LAST_INFO }; @@ -690,15 +692,6 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) emit_hypervisor_memory_failure(MEMORY_FAILURE_ACTION_IGNORE, false); } -static void kvm_reset_exception(CPUX86State *env) -{ - env->exception_nr = -1; - env->exception_pending = 0; - env->exception_injected = 0; - env->exception_has_payload = false; - env->exception_payload = 0; -} - static void kvm_queue_exception(CPUX86State *env, int32_t exception_nr, uint8_t exception_has_payload, @@ -731,38 +724,6 @@ static void kvm_queue_exception(CPUX86State *env, } } -static int kvm_inject_mce_oldstyle(X86CPU *cpu) -{ - CPUX86State *env = &cpu->env; - - if (!kvm_has_vcpu_events() && env->exception_nr == EXCP12_MCHK) { - unsigned int bank, bank_num = env->mcg_cap & 0xff; - struct kvm_x86_mce mce; - - kvm_reset_exception(env); - - /* - * There must be at least one bank in use if an MCE is pending. - * Find it and use its values for the event injection. - */ - for (bank = 0; bank < bank_num; bank++) { - if (env->mce_banks[bank * 4 + 1] & MCI_STATUS_VAL) { - break; - } - } - assert(bank < bank_num); - - mce.bank = bank; - mce.status = env->mce_banks[bank * 4 + 1]; - mce.mcg_status = env->mcg_status; - mce.addr = env->mce_banks[bank * 4 + 2]; - mce.misc = env->mce_banks[bank * 4 + 3]; - - return kvm_vcpu_ioctl(CPU(cpu), KVM_X86_SET_MCE, &mce); - } - return 0; -} - static void cpu_update_state(void *opaque, bool running, RunState state) { CPUX86State *env = opaque; @@ -4359,10 +4320,6 @@ static int kvm_put_vcpu_events(X86CPU *cpu, int level) CPUX86State *env = &cpu->env; struct kvm_vcpu_events events = {}; - if (!kvm_has_vcpu_events()) { - return 0; - } - events.flags = 0; if (has_exception_payload) { @@ -4430,10 +4387,6 @@ static int kvm_get_vcpu_events(X86CPU *cpu) struct kvm_vcpu_events events; int ret; - if (!kvm_has_vcpu_events()) { - return 0; - } - memset(&events, 0, sizeof(events)); ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_VCPU_EVENTS, &events); if (ret < 0) { @@ -4499,37 +4452,6 @@ static int kvm_get_vcpu_events(X86CPU *cpu) return 0; } -static int kvm_guest_debug_workarounds(X86CPU *cpu) -{ - CPUState *cs = CPU(cpu); - CPUX86State *env = &cpu->env; - int ret = 0; - unsigned long reinject_trap = 0; - - if (!kvm_has_vcpu_events()) { - if (env->exception_nr == EXCP01_DB) { - reinject_trap = KVM_GUESTDBG_INJECT_DB; - } else if (env->exception_injected == EXCP03_INT3) { - reinject_trap = KVM_GUESTDBG_INJECT_BP; - } - kvm_reset_exception(env); - } - - /* - * Kernels before KVM_CAP_X86_ROBUST_SINGLESTEP overwrote flags.TF - * injected via SET_GUEST_DEBUG while updating GP regs. Work around this - * by updating the debug state once again if single-stepping is on. - * Another reason to call kvm_update_guest_debug here is a pending debug - * trap raise by the guest. On kernels without SET_VCPU_EVENTS we have to - * reinject them via SET_GUEST_DEBUG. - */ - if (reinject_trap || - (!kvm_has_robust_singlestep() && cs->singlestep_enabled)) { - ret = kvm_update_guest_debug(cs, reinject_trap); - } - return ret; -} - static int kvm_put_debugregs(X86CPU *cpu) { CPUX86State *env = &cpu->env; @@ -4702,11 +4624,6 @@ int kvm_arch_put_registers(CPUState *cpu, int level) if (ret < 0) { return ret; } - /* must be before kvm_put_msrs */ - ret = kvm_inject_mce_oldstyle(x86_cpu); - if (ret < 0) { - return ret; - } ret = kvm_put_msrs(x86_cpu, level); if (ret < 0) { return ret; @@ -4730,11 +4647,6 @@ int kvm_arch_put_registers(CPUState *cpu, int level) if (ret < 0) { return ret; } - /* must be last */ - ret = kvm_guest_debug_workarounds(x86_cpu); - if (ret < 0) { - return ret; - } return 0; } From patchwork Wed Oct 18 16:37:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ftk/N4XV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c7j2NXQz20cx for ; Thu, 19 Oct 2023 03:41:53 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Yf-0001KX-EF; Wed, 18 Oct 2023 12:38:09 -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 1qt9YZ-00016I-DJ for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:04 -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 1qt9YX-0007PY-3o for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647080; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fffmKAk2Mzul0/4WuRS85RgZzOjDwr5HJtxi7DJFtFQ=; b=ftk/N4XV8u7wFJP65rE/95TxMBRVQjGfPvy29cbmIfiI8XbvxXLLMRkuJJ8RfZSgWlWUjV NOHTlZgBVyhccf3uwlVYeFvwCr+immb4RNJfiLYs9LAGS9M7L36hFNcvOx4F7BFML705AM 1IXz2H1At7IIQElXNz6qyJriInrPYJ4= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-9-LOLCYNMjOfNu7cJnbaqA-1; Wed, 18 Oct 2023 12:37:59 -0400 X-MC-Unique: 9-LOLCYNMjOfNu7cJnbaqA-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9bd7c682b33so532820066b.3 for ; Wed, 18 Oct 2023 09:37:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647077; x=1698251877; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fffmKAk2Mzul0/4WuRS85RgZzOjDwr5HJtxi7DJFtFQ=; b=dudeVwu6+sGrQFKOHqv+/Jd/l3kRI/mBLK+Uy4nvS6JGo6gaAxnK0ZMsJSBlp3JR8+ pW4B3lA81aKXwpLF/0rWzRhg1uywF7Bmy2cDCi+duUEZpReI+zY3Sj3N7nmEMpw3+NxJ pCcuWr/JhTbDjf09aw/ZkVbLyk89/ueg6zVvXszIFetR3lM6mRx7Ssauz5YJ3MeBfSKH jvIKaJXxcFKA49YVBO99y2fj77LZR7AXwlNvCOMevkvBQp1S/FRfSP+1x6jzrdopZ7Lq yNfAYvm9lZSRGampGkxKEPKEv5XURoKaUzpo3Cqjdm6SdHApZDPF9VlCc4NfwP9FvCt4 Mb3g== X-Gm-Message-State: AOJu0YxvA6NsTJ0ykATQ6j0zOI8PajtkJ2rjFDGtXcwu7XShLl86ugOm GzaxlgJLvleWa/Z8yGc/iY/tVoateSZQpcz49zzyxK5F6dp95Fall2oNrEeLmJrhDRmpdD2ac6P m9p6D2LfntvGjLG2pdDMdSSPa5Eu1N6RgewcbbEcrgHqIW+SToHeunXKm1t0j1JILQa79xCWqYn 8= X-Received: by 2002:a17:907:928e:b0:9ae:65a5:b6fa with SMTP id bw14-20020a170907928e00b009ae65a5b6famr4380089ejc.32.1697647077595; Wed, 18 Oct 2023 09:37:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFC2WvQk1pDekSqnBOafH+hSSQQPIc/aAqR8jRgQMy++ddruIh2kier/MlwGBb9TPOg+fVodg== X-Received: by 2002:a17:907:928e:b0:9ae:65a5:b6fa with SMTP id bw14-20020a170907928e00b009ae65a5b6famr4380071ejc.32.1697647077254; Wed, 18 Oct 2023 09:37:57 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id w14-20020a170906184e00b009a9fbeb15f2sm2039249eje.62.2023.10.18.09.37.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 14/17] kvm: i386: require KVM_CAP_MCE Date: Wed, 18 Oct 2023 18:37:25 +0200 Message-ID: <20231018163728.363879-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This was introduced in KVM in Linux 2.6.34, we can require it unconditionally. Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 5 ----- target/i386/kvm/kvm.c | 14 ++++---------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 608da41465d..41d388acff2 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3131,11 +3131,6 @@ bool kvm_has_sync_mmu(void) return kvm_state->sync_mmu; } -int kvm_has_robust_singlestep(void) -{ - return kvm_state->robust_singlestep; -} - int kvm_max_nested_state_length(void) { return kvm_state->max_nested_state_len; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 5db3fd0f4c4..6df8d56c87e 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -97,6 +97,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_INFO(XSAVE), KVM_CAP_INFO(VCPU_EVENTS), KVM_CAP_INFO(X86_ROBUST_SINGLESTEP), + KVM_CAP_INFO(MCE), KVM_CAP_LAST_INFO }; @@ -582,14 +583,8 @@ uint64_t kvm_arch_get_supported_msr_feature(KVMState *s, uint32_t index) static int kvm_get_mce_cap_supported(KVMState *s, uint64_t *mce_cap, int *max_banks) { - int r; - - r = kvm_check_extension(s, KVM_CAP_MCE); - if (r > 0) { - *max_banks = r; - return kvm_ioctl(s, KVM_X86_GET_MCE_CAP_SUPPORTED, mce_cap); - } - return -ENOSYS; + *max_banks = kvm_check_extension(s, KVM_CAP_MCE); + return kvm_ioctl(s, KVM_X86_GET_MCE_CAP_SUPPORTED, mce_cap); } static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, int code) @@ -2116,8 +2111,7 @@ int kvm_arch_init_vcpu(CPUState *cs) if (((env->cpuid_version >> 8)&0xF) >= 6 && (env->features[FEAT_1_EDX] & (CPUID_MCE | CPUID_MCA)) == - (CPUID_MCE | CPUID_MCA) - && kvm_check_extension(cs->kvm_state, KVM_CAP_MCE) > 0) { + (CPUID_MCE | CPUID_MCA)) { uint64_t mcg_cap, unsupported_caps; int banks; int ret; From patchwork Wed Oct 18 16:37:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YXrwXrjw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c3y5zfRz23kB for ; Thu, 19 Oct 2023 03:38:38 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Yq-0001P5-Kw; Wed, 18 Oct 2023 12:38:21 -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 1qt9Yb-0001CY-MF for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:06 -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 1qt9Ya-0007Po-16 for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9wZuj85GLu2soE71yr6wZpncdjmSTCMFr6YGQ05DMqA=; b=YXrwXrjwsVWzp07KdI/yZLCx5JhLYtlCCY9GdMumoU98AQDWzFP/9daBRClDMuYInbNfhb hQw0Czw/jKe6aQDvUNGLTPRVltNokXD/0F1u7bkjsxRqO9ohWnnIUYSsASA+NZNcPPlxAY 6nnyY+RRALr5kPPiCZ6EU/X/ghnoZh0= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-tKU5JgGpODmxoyDZQuOifA-1; Wed, 18 Oct 2023 12:38:01 -0400 X-MC-Unique: tKU5JgGpODmxoyDZQuOifA-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9be601277c2so338281366b.2 for ; Wed, 18 Oct 2023 09:38:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647079; x=1698251879; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9wZuj85GLu2soE71yr6wZpncdjmSTCMFr6YGQ05DMqA=; b=B1qdlxXVX3s8RPPLPQIW3XdihZS/hL9xokogcyt1C8e1ZoYLvR+/oZXrtWbJn18tsz GReO3xyWWZjpGdrOizBWj/UxiMg+rxr84EuaMXPtJ4rQbdtxeoikztkMnFn5e9fLzpmU IiRaWtxvqUKINhCXu3RG75BOaa0wpvO4VX7hdyqezmoPuF4mF/XBt/7Az04jVH0d9FcE VHN5i3SlHKzcGauS0ozECfrxpVnmd8jTRHT7lG0825xCu3cfZ6fuFKKSo6p0dgRFARz+ vyqnlchPVg7oatLcVHp2HLHw5csNZG83wi5xcJPjY0uUk1DTnYn9i342jLpXnrGTW75Q FBiw== X-Gm-Message-State: AOJu0YwoAl+N6z+kFsv6kyXpzJ8sEwpIQlxbzUG2Ss7v7fjhsJTwSJNL eDFSqLFBFLr0SL4eHdvj5p3LBu4Hf1AjmlGx6taLxCuoBPxfFo21yMhXkaqH/wInlYV7WbxgBRz Gdmd9jTdcILhMb7M/ovEXL5DuMFhwHLf1e9vljGiIh5O+smrBJEaD3cdtpP31OKIPtey5lbvkAH k= X-Received: by 2002:a17:907:1c0c:b0:9be:b43c:38dc with SMTP id nc12-20020a1709071c0c00b009beb43c38dcmr5158595ejc.12.1697647079219; Wed, 18 Oct 2023 09:37:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElodZlgk6BSTcR/AuYZsnJSb8PuzbXHMHQByllDBRwe46NfZpwB1Kb2LxBL7eVj6hZJDviYw== X-Received: by 2002:a17:907:1c0c:b0:9be:b43c:38dc with SMTP id nc12-20020a1709071c0c00b009beb43c38dcmr5158581ejc.12.1697647078867; Wed, 18 Oct 2023 09:37:58 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id h9-20020a170906260900b009ae3d711fd9sm1987388ejc.69.2023.10.18.09.37.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 15/17] kvm: i386: require KVM_CAP_ADJUST_CLOCK Date: Wed, 18 Oct 2023 18:37:26 +0200 Message-ID: <20231018163728.363879-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This was introduced in KVM in Linux 2.6.33, we can require it unconditionally. KVM_CLOCK_TSC_STABLE was only added in Linux 4.9, for now do not require it (though it would allow the removal of some pretty yucky code). Signed-off-by: Paolo Bonzini --- hw/i386/kvm/clock.c | 4 ---- target/i386/kvm/kvm.c | 6 +----- target/i386/kvm/kvm_i386.h | 1 - 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c index f25977d3f68..e756b0aa43f 100644 --- a/hw/i386/kvm/clock.c +++ b/hw/i386/kvm/clock.c @@ -333,10 +333,6 @@ void kvmclock_create(bool create_always) X86CPU *cpu = X86_CPU(first_cpu); assert(kvm_enabled()); - if (!kvm_has_adjust_clock()) { - return; - } - if (create_always || cpu->env.features[FEAT_KVM] & ((1ULL << KVM_FEATURE_CLOCKSOURCE) | (1ULL << KVM_FEATURE_CLOCKSOURCE2))) { diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 6df8d56c87e..df131fcc8b1 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -98,6 +98,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_INFO(VCPU_EVENTS), KVM_CAP_INFO(X86_ROBUST_SINGLESTEP), KVM_CAP_INFO(MCE), + KVM_CAP_INFO(ADJUST_CLOCK), KVM_CAP_LAST_INFO }; @@ -177,11 +178,6 @@ bool kvm_has_adjust_clock_stable(void) return (ret & KVM_CLOCK_TSC_STABLE); } -bool kvm_has_adjust_clock(void) -{ - return kvm_check_extension(kvm_state, KVM_CAP_ADJUST_CLOCK); -} - bool kvm_has_exception_payload(void) { return has_exception_payload; diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 55d4e68c342..7e60ea4f23f 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -50,7 +50,6 @@ void kvm_request_xsave_components(X86CPU *cpu, uint64_t mask); #ifdef CONFIG_KVM -bool kvm_has_adjust_clock(void); bool kvm_has_adjust_clock_stable(void); bool kvm_has_exception_payload(void); void kvm_synchronize_all_tsc(void); From patchwork Wed Oct 18 16:37:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N0w9l9Ft; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c785F62z20cx for ; Thu, 19 Oct 2023 03:41:24 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Yl-0001O9-Iu; Wed, 18 Oct 2023 12:38:17 -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 1qt9Yc-0001Co-Hb for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt9Ya-0007Px-QP for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l81+EyOeU3LSHiNMN6aj26DOrdFpEtWh0cb0/Y84qOo=; b=N0w9l9Ftwt6G8ZHQV7t8EWkXvGTyadHuKy1olAaxt0qKgDkyWD6C/fmZesKO5Uypg7w6HG DDMM5mlwm5+APHKKkIaSXpr61sA9w0U55ViAaCKQhrZ8naAbvvzsf8oAU0FPv9buCaHoxJ fn0o8SaFbKnrAHwDIwyhR3+lZpImdPc= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-97-iiVz7xmWM9y3WP4Rjng0Gw-1; Wed, 18 Oct 2023 12:38:02 -0400 X-MC-Unique: iiVz7xmWM9y3WP4Rjng0Gw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9a9e12a3093so778494366b.0 for ; Wed, 18 Oct 2023 09:38:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647081; x=1698251881; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l81+EyOeU3LSHiNMN6aj26DOrdFpEtWh0cb0/Y84qOo=; b=TOxyvDnhRngyPtaj4WwOfe1nQhceW5ETai/1RX7hgoSJYn9kyC9pjyjfuUYhKHMhBz RhG0QofxXdra2L3R+i6AXkwXrJrMB6exbfLASRFiU9aAeAAIxDggQgAZI9crH+u1WXEH NYoIMCrSwVVw8neLVqu+rw6Ubdixepx1DczMC12wibxR0z4cF3ShCPyzRxTBOrW4NFe7 yaSt6a8nqrwWqolFgEb6XsYM/XcZ0HP9N5gqqiHsvdDqNreGlRwQdpeCTFkSowVjaJZ7 ssQr3aH+9SLj+PCh/FePeRIattineBucAJtYa0o3G/LIFeUTbRqn7esZTJ9uAmPeCGQo KKRw== X-Gm-Message-State: AOJu0YwuEOMcTYRqxw+UBfnxusPm3cNE6w5Lyw74bGFU5ub5uP1gwEri bzqloPFHOXNH+4L1b/9sRfqJmpQxurmZbrpy8rMro56SJQ8ya4YWldllFH3hnyt0isDgE06snq/ s+sQ+90PoiY5clefFuZBrcNxRSsclnft5M0vbAh9+C3kXVP3Sg+Bw9DstKLUZWjaXGXZQ8JDMVG c= X-Received: by 2002:a17:907:7203:b0:9aa:1794:945b with SMTP id dr3-20020a170907720300b009aa1794945bmr4961575ejc.22.1697647080857; Wed, 18 Oct 2023 09:38:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGA0V9+RH6GJAcpy5133H6UidEEqPjulDoN4+vNartrnn20sf11H+qt3FbEEDJMNHb8l3SUTg== X-Received: by 2002:a17:907:7203:b0:9aa:1794:945b with SMTP id dr3-20020a170907720300b009aa1794945bmr4961555ejc.22.1697647080474; Wed, 18 Oct 2023 09:38:00 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id g2-20020a50d5c2000000b0053ebe6c1396sm3131611edj.27.2023.10.18.09.37.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:37:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 16/17] kvm: i386: require KVM_CAP_SET_IDENTITY_MAP_ADDR Date: Wed, 18 Oct 2023 18:37:27 +0200 Message-ID: <20231018163728.363879-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.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.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This was introduced in KVM in Linux 2.6.32, we can require it unconditionally. Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index df131fcc8b1..a3d52cb538f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -99,6 +99,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = { KVM_CAP_INFO(X86_ROBUST_SINGLESTEP), KVM_CAP_INFO(MCE), KVM_CAP_INFO(ADJUST_CLOCK), + KVM_CAP_INFO(SET_IDENTITY_MAP_ADDR), KVM_CAP_LAST_INFO }; @@ -2600,20 +2601,13 @@ int kvm_arch_init(MachineState *ms, KVMState *s) * In order to use vm86 mode, an EPT identity map and a TSS are needed. * Since these must be part of guest physical memory, we need to allocate * them, both by setting their start addresses in the kernel and by - * creating a corresponding e820 entry. We need 4 pages before the BIOS. - * - * Older KVM versions may not support setting the identity map base. In - * that case we need to stick with the default, i.e. a 256K maximum BIOS - * size. + * creating a corresponding e820 entry. We need 4 pages before the BIOS, + * so this value allows up to 16M BIOSes. */ - if (kvm_check_extension(s, KVM_CAP_SET_IDENTITY_MAP_ADDR)) { - /* Allows up to 16M BIOSes. */ - identity_base = 0xfeffc000; - - ret = kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, &identity_base); - if (ret < 0) { - return ret; - } + identity_base = 0xfeffc000; + ret = kvm_vm_ioctl(s, KVM_SET_IDENTITY_MAP_ADDR, &identity_base); + if (ret < 0) { + return ret; } /* Set TSS base one page after EPT identity map. */ From patchwork Wed Oct 18 16:37:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1851046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QKiRYNsk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S9c410z7Nz20Pd for ; Thu, 19 Oct 2023 03:38:41 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qt9Z0-0001du-72; Wed, 18 Oct 2023 12:38:31 -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 1qt9Yn-0001PV-Hz for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qt9Yl-0007QU-Qn for qemu-devel@nongnu.org; Wed, 18 Oct 2023 12:38:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697647095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EKZyCSNjjP6HQEmWy1mFmMwgg9xL+PtkdeavECS0iEU=; b=QKiRYNskGuZkSHBFzvaSorg2DSygW4yUAkkkGfCZut5PjnIPnq1AHzYPV+ZHHm5MHCBDIw niQhgohSXyQ6Bl0tM1aO0Oc6Aqfq7ogDAsFq5t1pVqVEcdLxasKn/+XHhSj6fZirezTAGp 6mkwCoYBRklyAzA45+i3/nknG2tmESs= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-159-QLH6UMIHODiV2eyG2HMRPA-1; Wed, 18 Oct 2023 12:38:03 -0400 X-MC-Unique: QLH6UMIHODiV2eyG2HMRPA-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-9c15543088aso433908266b.1 for ; Wed, 18 Oct 2023 09:38:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697647082; x=1698251882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EKZyCSNjjP6HQEmWy1mFmMwgg9xL+PtkdeavECS0iEU=; b=RbkOBYyn9uj8DrSxBEoDG8NDJiSwNcJ9XbifQuWJilmmkhWQjO+5FTgJQMhUZFNUX4 uzCfgyAA3GG8eDrLVuWla0T6b52UysbhKX82ILszp7MAE17GTJ4yodIJ7niQ2ylPuTQt IpoCAvqkSL29I9JcU+Tvn85Q241lVGJ6+0xZK/9zpUlDSSdGK7YukR1iU5/3BNZheIw2 qQXm8vLZJ4PGRuIyXl812lWc/AqzL7th3ky4xyZ7MR6tiynHmtibLxLPcEY5ZbmdK6Qm M3bAd3wCo0d3ogqU6Cw9WYdrFufIjurWoQy9NEx7pbgwiBUExpNf45BIova1YT9yHmfJ W0Yg== X-Gm-Message-State: AOJu0Yyww1Tw9uVTWEeu0WLSdG2WHcvMuYti7J0zy5Ox5zGj7df6kFGu HqxP3lmATHVgVYgayRn/UW1lA0PtCObK/dwHE1PcObTYpLsFeZrw5rqcyINya6YSCw52YQjuDXi 4YALeG7L8mrmxN+9T8ARKdzPUncLkloYSITdd0OuviggibHrQiaQzBShomPTGO0QBh3wqRXbwuK 8= X-Received: by 2002:a17:906:4fc7:b0:9ae:705a:8451 with SMTP id i7-20020a1709064fc700b009ae705a8451mr5126818ejw.25.1697647082350; Wed, 18 Oct 2023 09:38:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH18g87aEWDL6xpW6jb5elk1saANSTB/7ejguy3d0GUzegtHsgbgJhYP8AOIel1s2EbspBIuQ== X-Received: by 2002:a17:906:4fc7:b0:9ae:705a:8451 with SMTP id i7-20020a1709064fc700b009ae705a8451mr5126804ejw.25.1697647081978; Wed, 18 Oct 2023 09:38:01 -0700 (PDT) Received: from [192.168.10.118] ([2001:b07:6468:f312:63a7:c72e:ea0e:6045]) by smtp.gmail.com with ESMTPSA id mb8-20020a170906eb0800b0098951bb4dc3sm1963879ejb.184.2023.10.18.09.38.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 09:38:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 17/17] kvm: i8254: require KVM_CAP_PIT2 and KVM_CAP_PIT_STATE2 Date: Wed, 18 Oct 2023 18:37:28 +0200 Message-ID: <20231018163728.363879-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018163728.363879-1-pbonzini@redhat.com> References: <20231018163728.363879-1-pbonzini@redhat.com> MIME-Version: 1.0 Received-SPF: pass client-ip=170.10.129.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.001, RCVD_IN_MSPIKE_WL=0.001, 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- hw/i386/kvm/i8254.c | 38 ++++++++++++-------------------------- hw/i386/pc.c | 6 +----- target/i386/kvm/kvm.c | 7 ------- target/i386/kvm/kvm_i386.h | 1 - 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c index a649b2b7caf..e49b9c4b565 100644 --- a/hw/i386/kvm/i8254.c +++ b/hw/i386/kvm/i8254.c @@ -97,24 +97,12 @@ static void kvm_pit_get(PITCommonState *pit) return; } - if (kvm_has_pit_state2()) { - ret = kvm_vm_ioctl(kvm_state, KVM_GET_PIT2, &kpit); - if (ret < 0) { - fprintf(stderr, "KVM_GET_PIT2 failed: %s\n", strerror(-ret)); - abort(); - } - pit->channels[0].irq_disabled = kpit.flags & KVM_PIT_FLAGS_HPET_LEGACY; - } else { - /* - * kvm_pit_state2 is superset of kvm_pit_state struct, - * so we can use it for KVM_GET_PIT as well. - */ - ret = kvm_vm_ioctl(kvm_state, KVM_GET_PIT, &kpit); - if (ret < 0) { - fprintf(stderr, "KVM_GET_PIT failed: %s\n", strerror(-ret)); - abort(); - } + ret = kvm_vm_ioctl(kvm_state, KVM_GET_PIT2, &kpit); + if (ret < 0) { + fprintf(stderr, "KVM_GET_PIT2 failed: %s\n", strerror(-ret)); + abort(); } + pit->channels[0].irq_disabled = kpit.flags & KVM_PIT_FLAGS_HPET_LEGACY; for (i = 0; i < 3; i++) { kchan = &kpit.channels[i]; sc = &pit->channels[i]; @@ -170,12 +158,9 @@ static void kvm_pit_put(PITCommonState *pit) kchan->count_load_time = sc->count_load_time - s->kernel_clock_offset; } - ret = kvm_vm_ioctl(kvm_state, - kvm_has_pit_state2() ? KVM_SET_PIT2 : KVM_SET_PIT, - &kpit); + ret = kvm_vm_ioctl(kvm_state, KVM_SET_PIT2, &kpit); if (ret < 0) { - fprintf(stderr, "%s failed: %s\n", - kvm_has_pit_state2() ? "KVM_SET_PIT2" : "KVM_SET_PIT", + fprintf(stderr, "KVM_SET_PIT2 failed: %s\n", strerror(-ret)); abort(); } @@ -261,11 +246,12 @@ static void kvm_pit_realizefn(DeviceState *dev, Error **errp) }; int ret; - if (kvm_check_extension(kvm_state, KVM_CAP_PIT2)) { - ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_PIT2, &config); - } else { - ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_PIT); + if (!kvm_check_extension(kvm_state, KVM_CAP_PIT_STATE2) || + !kvm_check_extension(kvm_state, KVM_CAP_PIT2)) { + error_setg(errp, "In-kernel PIT not available"); } + + ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_PIT2, &config); if (ret < 0) { error_setg(errp, "Create kernel PIC irqchip failed: %s", strerror(-ret)); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index bb3854d1d08..f3793dd0633 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1213,12 +1213,8 @@ void pc_basic_device_init(struct PCMachineState *pcms, /* * Check if an HPET shall be created. - * - * Without KVM_CAP_PIT_STATE2, we cannot switch off the in-kernel PIT - * when the HPET wants to take over. Thus we have to disable the latter. */ - if (pcms->hpet_enabled && (!kvm_irqchip_in_kernel() || - kvm_has_pit_state2())) { + if (pcms->hpet_enabled) { hpet = qdev_try_new(TYPE_HPET); if (!hpet) { error_report("couldn't create HPET device"); diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index a3d52cb538f..cbb8db6ea70 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -145,7 +145,6 @@ static uint32_t num_architectural_pmu_fixed_counters; static int has_xsave2; static int has_xcrs; -static int has_pit_state2; static int has_sregs2; static int has_exception_payload; static int has_triple_fault_event; @@ -162,11 +161,6 @@ static KVMMSRHandlers msr_handlers[KVM_MSR_FILTER_MAX_RANGES]; static RateLimit bus_lock_ratelimit_ctrl; static int kvm_get_one_msr(X86CPU *cpu, int index, uint64_t *value); -bool kvm_has_pit_state2(void) -{ - return !!has_pit_state2; -} - bool kvm_has_smm(void) { return kvm_vm_check_extension(kvm_state, KVM_CAP_X86_SMM); @@ -2543,7 +2537,6 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } has_xcrs = kvm_check_extension(s, KVM_CAP_XCRS); - has_pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2); has_sregs2 = kvm_check_extension(s, KVM_CAP_SREGS2) > 0; hv_vpindex_settable = kvm_check_extension(s, KVM_CAP_HYPERV_VP_INDEX); diff --git a/target/i386/kvm/kvm_i386.h b/target/i386/kvm/kvm_i386.h index 7e60ea4f23f..30fedcffea3 100644 --- a/target/i386/kvm/kvm_i386.h +++ b/target/i386/kvm/kvm_i386.h @@ -33,7 +33,6 @@ bool kvm_has_smm(void); bool kvm_enable_x2apic(void); bool kvm_hv_vpindex_settable(void); -bool kvm_has_pit_state2(void); bool kvm_enable_sgx_provisioning(KVMState *s); bool kvm_hyperv_expand_features(X86CPU *cpu, Error **errp);