From patchwork Wed Aug 21 14:26:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13771680 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C96C1B1D50 for ; Wed, 21 Aug 2024 14:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724250404; cv=none; b=QxCRew73WhM4ld/zs6IgVpLCNlZBe371XlBXCgMQJn9zXDdmfkwgBieZRCAAWq50rJJKd176HxiGw/ZKKcuiQ6haNLXnj6HZ4kjF4+m1zSLHemUiC4bT4VZ+E+7ephc9cnV2TV/SWb6xVoMZYI3mYpmcdnUeH4KYOqxjFH1EX4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724250404; c=relaxed/simple; bh=PWtc5aldsHtv2h7Ede3x534t98EKCHMOqmWv9fq7rK8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=juCqZ9SuWkFBYJh3M6UJdE1AaVfLowJ2qdJMQgp9gW9WKKfoeqC6Mpvqne+8+WafVqJm7DP6QFEHfHhsWI5dj+C2MYsnhWyekzSTQwmqV+gvlW/p5+5JrIwI3Q6ma/iDWSJa3ARLyrWKZW3BI9eZg50TVspPuZJMRSg9Or0ItyE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=WTStECn9; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="WTStECn9" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42817f1eb1fso54868985e9.1 for ; Wed, 21 Aug 2024 07:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1724250401; x=1724855201; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pc3oH83451CeWS4VKLJb3/MW3Irx8Ealej33KWVBpwI=; b=WTStECn9OjBACfaxF5bJEjwfQdFkLkx7LJ0Wu6hmlKPSeBOIcAw76CCpaJxZTcZ47S LOmfIjogNzQBs5U4xSFvfvUWXaoE4l1bsUx5eu+4Jh0iWbWPu3KSO92NN9Q/yZixeL9b hQIIg1+0yUhQSFZtsLSj1mFRYVsGu8NOdAwN1ZnjIAwR9fRrTnyJN2Y5TlD+k56h0WhP APkC86GdTUcr1dp5qETvtVTgAx49LeLuNc76qEzgSdL7rP/1TWpdbZPR1lyY2gWWbDvd uJ03s8h4NmLRqXtfRS9oLH3rf8KBmdxW7tbvSprNvMGhhebP9fxdvv2UIFltXs4xaukK 1mVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724250401; x=1724855201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pc3oH83451CeWS4VKLJb3/MW3Irx8Ealej33KWVBpwI=; b=E6CMNNWCFFL8KXT4Yzo5QTgSijQ5avYkd6gG/cSCZCyQur5mutNpNfygeI0+uxNp49 2bpt9ZPIH2bkNx1N4KWP5j+LVmgGQwpMX44AinED9mOJCchBVJKemaXW9Nzoevne/d2W pztDgK5R84tidmxTyw/dXm4MVkuBX4fO//4t9MEGUgSiYNDO5RAmzgbW5jI3oIpUid75 mSzR/ObjZHCovOneqE3dNa51mnRSqgjmfYkalEWHN92lBsZbh1TADYynitAPI2nllzaf XfrPlv1FSJ47fLGp3NabefW5pUV2rC6o6Z9NrEg+MELa3En6qOj8cZQcevroShHrlvPS z9Ow== X-Forwarded-Encrypted: i=1; AJvYcCUpqGifVpdPRqW3BCH13AplPbwpilArAfLDc27EOJ3dBhYoAFvqzUSrCncELndnP4/CFiE=@vger.kernel.org X-Gm-Message-State: AOJu0YwYZxHFCKPW/3obfUabZQpyofOuu5+QKdboW4jrquGWCoTt7cwj d5UIxaAK85lKWwWS14FLoWKaSObWYiOpPQGnNhZzOry1T/u7qQYxe1nbs2uAo3s= X-Google-Smtp-Source: AGHT+IGKQ01goe26Qzs3n/MKI58ZfYTLt7lQKleX8xrbKlefkSmkxHuviKTprq/5KohjpfGQ8TtGGg== X-Received: by 2002:a05:600c:3581:b0:428:e09d:3c with SMTP id 5b1f17b1804b1-42abf0a8d02mr16517105e9.33.1724250400071; Wed, 21 Aug 2024 07:26:40 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abebc34ddsm28646765e9.0.2024.08.21.07.26.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 07:26:39 -0700 (PDT) From: Anup Patel To: Will Deacon , julien.thierry.kdev@gmail.com, maz@kernel.org Cc: Paolo Bonzini , Atish Patra , Andrew Jones , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Anup Patel Subject: [kvmtool PATCH v3 1/4] Sync-up headers with Linux-6.10 kernel Date: Wed, 21 Aug 2024 19:56:07 +0530 Message-Id: <20240821142610.3297483-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821142610.3297483-1-apatel@ventanamicro.com> References: <20240821142610.3297483-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We sync-up Linux headers to get latest KVM RISC-V headers having Sscofpmf support. Signed-off-by: Anup Patel Anup Patel --- include/linux/kvm.h | 4 +- include/linux/virtio_net.h | 143 +++++++++++++++++++++++++++++++++++++ riscv/include/asm/kvm.h | 1 + x86/include/asm/kvm.h | 22 +++++- 4 files changed, 166 insertions(+), 4 deletions(-) diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 2190adb..d03842a 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -1221,9 +1221,9 @@ struct kvm_vfio_spapr_tce { /* Available with KVM_CAP_SPAPR_RESIZE_HPT */ #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt) #define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt) -/* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ +/* Available with KVM_CAP_PPC_MMU_RADIX or KVM_CAP_PPC_MMU_HASH_V3 */ #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg) -/* Available with KVM_CAP_PPC_RADIX_MMU */ +/* Available with KVM_CAP_PPC_MMU_RADIX */ #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info) /* Available with KVM_CAP_PPC_GET_CPU_CHAR */ #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char) diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h index cc65ef0..ac91747 100644 --- a/include/linux/virtio_net.h +++ b/include/linux/virtio_net.h @@ -56,6 +56,7 @@ #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_DEVICE_STATS 50 /* Device can provide device-level statistics. */ #define VIRTIO_NET_F_VQ_NOTF_COAL 52 /* Device supports virtqueue notification coalescing */ #define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalescing */ #define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */ @@ -406,4 +407,146 @@ struct virtio_net_ctrl_coal_vq { struct virtio_net_ctrl_coal coal; }; +/* + * Device Statistics + */ +#define VIRTIO_NET_CTRL_STATS 8 +#define VIRTIO_NET_CTRL_STATS_QUERY 0 +#define VIRTIO_NET_CTRL_STATS_GET 1 + +struct virtio_net_stats_capabilities { + +#define VIRTIO_NET_STATS_TYPE_CVQ (1ULL << 32) + +#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1ULL << 0) +#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1ULL << 1) +#define VIRTIO_NET_STATS_TYPE_RX_GSO (1ULL << 2) +#define VIRTIO_NET_STATS_TYPE_RX_SPEED (1ULL << 3) + +#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1ULL << 16) +#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1ULL << 17) +#define VIRTIO_NET_STATS_TYPE_TX_GSO (1ULL << 18) +#define VIRTIO_NET_STATS_TYPE_TX_SPEED (1ULL << 19) + + __le64 supported_stats_types[1]; +}; + +struct virtio_net_ctrl_queue_stats { + struct { + __le16 vq_index; + __le16 reserved[3]; + __le64 types_bitmap[1]; + } stats[1]; +}; + +struct virtio_net_stats_reply_hdr { +#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 32 + +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 0 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 1 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 2 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED 3 + +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 16 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 17 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 18 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED 19 + __u8 type; + __u8 reserved; + __le16 vq_index; + __le16 reserved1; + __le16 size; +}; + +struct virtio_net_stats_cvq { + struct virtio_net_stats_reply_hdr hdr; + + __le64 command_num; + __le64 ok_num; +}; + +struct virtio_net_stats_rx_basic { + struct virtio_net_stats_reply_hdr hdr; + + __le64 rx_notifications; + + __le64 rx_packets; + __le64 rx_bytes; + + __le64 rx_interrupts; + + __le64 rx_drops; + __le64 rx_drop_overruns; +}; + +struct virtio_net_stats_tx_basic { + struct virtio_net_stats_reply_hdr hdr; + + __le64 tx_notifications; + + __le64 tx_packets; + __le64 tx_bytes; + + __le64 tx_interrupts; + + __le64 tx_drops; + __le64 tx_drop_malformed; +}; + +struct virtio_net_stats_rx_csum { + struct virtio_net_stats_reply_hdr hdr; + + __le64 rx_csum_valid; + __le64 rx_needs_csum; + __le64 rx_csum_none; + __le64 rx_csum_bad; +}; + +struct virtio_net_stats_tx_csum { + struct virtio_net_stats_reply_hdr hdr; + + __le64 tx_csum_none; + __le64 tx_needs_csum; +}; + +struct virtio_net_stats_rx_gso { + struct virtio_net_stats_reply_hdr hdr; + + __le64 rx_gso_packets; + __le64 rx_gso_bytes; + __le64 rx_gso_packets_coalesced; + __le64 rx_gso_bytes_coalesced; +}; + +struct virtio_net_stats_tx_gso { + struct virtio_net_stats_reply_hdr hdr; + + __le64 tx_gso_packets; + __le64 tx_gso_bytes; + __le64 tx_gso_segments; + __le64 tx_gso_segments_bytes; + __le64 tx_gso_packets_noseg; + __le64 tx_gso_bytes_noseg; +}; + +struct virtio_net_stats_rx_speed { + struct virtio_net_stats_reply_hdr hdr; + + /* rx_{packets,bytes}_allowance_exceeded are too long. So rename to + * short name. + */ + __le64 rx_ratelimit_packets; + __le64 rx_ratelimit_bytes; +}; + +struct virtio_net_stats_tx_speed { + struct virtio_net_stats_reply_hdr hdr; + + /* tx_{packets,bytes}_allowance_exceeded are too long. So rename to + * short name. + */ + __le64 tx_ratelimit_packets; + __le64 tx_ratelimit_bytes; +}; + #endif /* _UAPI_LINUX_VIRTIO_NET_H */ diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h index b1c503c..e878e7c 100644 --- a/riscv/include/asm/kvm.h +++ b/riscv/include/asm/kvm.h @@ -167,6 +167,7 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZFA, KVM_RISCV_ISA_EXT_ZTSO, KVM_RISCV_ISA_EXT_ZACAS, + KVM_RISCV_ISA_EXT_SSCOFPMF, KVM_RISCV_ISA_EXT_MAX, }; diff --git a/x86/include/asm/kvm.h b/x86/include/asm/kvm.h index ef11aa4..9fae1b7 100644 --- a/x86/include/asm/kvm.h +++ b/x86/include/asm/kvm.h @@ -457,8 +457,13 @@ struct kvm_sync_regs { #define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001 -/* attributes for system fd (group 0) */ -#define KVM_X86_XCOMP_GUEST_SUPP 0 +/* vendor-independent attributes for system fd (group 0) */ +#define KVM_X86_GRP_SYSTEM 0 +# define KVM_X86_XCOMP_GUEST_SUPP 0 + +/* vendor-specific groups and attributes for system fd */ +#define KVM_X86_GRP_SEV 1 +# define KVM_X86_SEV_VMSA_FEATURES 0 struct kvm_vmx_nested_state_data { __u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE]; @@ -689,6 +694,9 @@ enum sev_cmd_id { /* Guest Migration Extension */ KVM_SEV_SEND_CANCEL, + /* Second time is the charm; improved versions of the above ioctls. */ + KVM_SEV_INIT2, + KVM_SEV_NR_MAX, }; @@ -700,6 +708,14 @@ struct kvm_sev_cmd { __u32 sev_fd; }; +struct kvm_sev_init { + __u64 vmsa_features; + __u32 flags; + __u16 ghcb_version; + __u16 pad1; + __u32 pad2[8]; +}; + struct kvm_sev_launch_start { __u32 handle; __u32 policy; @@ -856,5 +872,7 @@ struct kvm_hyperv_eventfd { #define KVM_X86_DEFAULT_VM 0 #define KVM_X86_SW_PROTECTED_VM 1 +#define KVM_X86_SEV_VM 2 +#define KVM_X86_SEV_ES_VM 3 #endif /* _ASM_X86_KVM_H */ From patchwork Wed Aug 21 14:26:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13771681 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A15C71B1D4B for ; Wed, 21 Aug 2024 14:26:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724250410; cv=none; b=rtSLvRzClcoipwr0HXHCg2v+D849iQkUguaqh6j7BNu9WeyMz/R5OL2y6F32YJWhUnnwwQuMACBiBNvJovXNk5eFtF5ujzGY/H4f36dkWUL7x77HsSvgZILONel7wrO9PbFSOXu/ETKcRw/Fr63XtrVe9Y7cL6tz0nrHGjgU8Xo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724250410; c=relaxed/simple; bh=fy1jkpYpkE6qm2m79ms2b9vDyDR5YEymMlq2ISlxvCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UCfHLF+jxQ0CPbfY+/SBupTw3d8ZGREFL3qnvPpdbe/SQiWpeCPDN4FGlYV9IzimhTYVgwNBVG/5ZUHgvPSITXpZgYI+pRQ+Ezks3fQkqxekJ8jp2RSae+yh7h9bp7PIUV1FFgvG93pztvQjyGfW2nFZv8YpR+K9XpQc9e5nEvY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=C02l2bgP; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="C02l2bgP" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4280c55e488so5030875e9.0 for ; Wed, 21 Aug 2024 07:26:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1724250407; x=1724855207; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oINtVjqt1HSId9RPGFIf1FQmhq9XpHG+7bXI6iFdSBA=; b=C02l2bgPjRI3Z8ptrOOCKyoBam18rIhiDwhk9qZ1KwWVm4q86Uuuw3lcQUeGGCGd1T svqnyT8g51TymJ4DW4tDUsh9B0YenhioL1l2tscPttV0iSat7FfWyzty4HYEo+a6HhAZ ba/iSbRTD0pvMx3BHCje8IIIgbowXR7qb/f4cr4KTeE/+1KmMWL4MwKdgjymGtosStT6 TKgCqSN+W8H/5utWxmVSf3a/YiI7Loq4EN5f6pHQVEcknffvBVIntUFg55jY1fp83kyw ++CRQXDDtjT2CToVLZG4N1cAnfo4Vm/tWKE6mL7iHuPI8PhE6lt5SCOOWXY3fipT5o8v Wu1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724250407; x=1724855207; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oINtVjqt1HSId9RPGFIf1FQmhq9XpHG+7bXI6iFdSBA=; b=VcszavSn2r88OHf0Ab0+7zgAoMKTDD3KfHyEZdb9VGNih5gs90Vf3SdzIy2CohEHeX NoZtJ6ON6lxLpLLljjSAEF3UlfYOJy7G+KtPi10070kb3YMQ1SH9/QWmr0btcc/SoYAj 6qGzG4KfZvw+XrMTjwiKQb1rvM1ngePxndnCef6lLbhTrvcEI6UDf8QBcEZwuZjs9VDl xhQHColpuElx5oitv9s9lOsOWcyaLGYXhwmaN/0yquLf6gjPhAoEzroCNBrL08ZkXeAB YGME0w1SfAEyJfQH0IybEET43ee7XGowx9357wNUwLgdN+e4Rf3xXlaPvAXb4geudmkX ig3w== X-Forwarded-Encrypted: i=1; AJvYcCXcxODFSNITKYY9FYLlJCMYJl7LMJjHDFA8UfOKKKTHsW8Ix05nqr627meoaqafj9bUus0=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7dXuUKQ/brld/fwK8fnKfl4bvwrbK2gehlsLbOlS8XVQ43DJp BJ6d9+mo5f6j8IbjDsLvodFo/YkqMm7N10g9PM2tzo/WCfUcxZjhq0EVkapSvzg= X-Google-Smtp-Source: AGHT+IGAG+CtUJijxv36J+sCbfags7JKci6hApRnvL6bK+8fTcLvO3mKXdE7IxDPtcijvhliEfAxtg== X-Received: by 2002:a05:600c:3104:b0:424:8743:86b4 with SMTP id 5b1f17b1804b1-42abe654bb6mr14247895e9.6.1724250406586; Wed, 21 Aug 2024 07:26:46 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abebc34ddsm28646765e9.0.2024.08.21.07.26.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 07:26:46 -0700 (PDT) From: Anup Patel To: Will Deacon , julien.thierry.kdev@gmail.com, maz@kernel.org Cc: Paolo Bonzini , Atish Patra , Andrew Jones , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Atish Patra , Anup Patel Subject: [kvmtool PATCH v3 2/4] riscv: Add Sscofpmf extensiona support Date: Wed, 21 Aug 2024 19:56:08 +0530 Message-Id: <20240821142610.3297483-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821142610.3297483-1-apatel@ventanamicro.com> References: <20240821142610.3297483-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Atish Patra When the Sscofpmf extension is available expose it to the guest via device tree so that guest can use it. Signed-off-by: Atish Patra Signed-off-by: Anup Patel --- riscv/fdt.c | 1 + riscv/include/kvm/kvm-config-arch.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/riscv/fdt.c b/riscv/fdt.c index cf367b9..e331f80 100644 --- a/riscv/fdt.c +++ b/riscv/fdt.c @@ -18,6 +18,7 @@ struct isa_ext_info isa_info_arr[] = { /* sorted alphabetically */ {"smstateen", KVM_RISCV_ISA_EXT_SMSTATEEN}, {"ssaia", KVM_RISCV_ISA_EXT_SSAIA}, + {"sscofpmf", KVM_RISCV_ISA_EXT_SSCOFPMF}, {"sstc", KVM_RISCV_ISA_EXT_SSTC}, {"svinval", KVM_RISCV_ISA_EXT_SVINVAL}, {"svnapot", KVM_RISCV_ISA_EXT_SVNAPOT}, diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h index 17f0ceb..3fbc4f7 100644 --- a/riscv/include/kvm/kvm-config-arch.h +++ b/riscv/include/kvm/kvm-config-arch.h @@ -31,6 +31,9 @@ struct kvm_config_arch { OPT_BOOLEAN('\0', "disable-ssaia", \ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SSAIA], \ "Disable Ssaia Extension"), \ + OPT_BOOLEAN('\0', "disable-sscofpmf", \ + &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SSCOFPMF], \ + "Disable Sscofpmf Extension"), \ OPT_BOOLEAN('\0', "disable-sstc", \ &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SSTC], \ "Disable Sstc Extension"), \ From patchwork Wed Aug 21 14:26:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13771682 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A82DC1AD5F4 for ; Wed, 21 Aug 2024 14:26:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724250416; cv=none; b=AQyAwb+AvR5jO2HH6OaMYj9UtmUNxLQTU4RSQfRs+M5bPkQMndJ+b8A3blmLXCoXzc94bkLwnQU3i9q6Erku6B1Uv0cLz6pEAyTMAcRT0c59U0HgHw1o8HvfL3BvixjE8fiBFaBmVLNjiZMOBWk2rGoXaLyA4oQ4pZbh4GtBibs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724250416; c=relaxed/simple; bh=K+V7s4lhvmj533HTxynH3XTk1ifZ+Jcx/a/SUHWKnfU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XCAa245Gaz6Qfp35IJRSOBNbib5fgNXPN3tbM/KmegR7+QpllXy0Y9ihh4mW65jIzQ0JS13D+Ktv0sI0HX2rUerLEN6/Z+au9LlqpmtVIN0x88OYXCP6fFAJ7d8F+/nZOIrPrIuDLHQaVvfdFMkvr7F+oSyavkvEk7K3jkktvcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=eLzFTYDS; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="eLzFTYDS" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42ab99fb45dso19879225e9.1 for ; Wed, 21 Aug 2024 07:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1724250413; x=1724855213; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BXdIh8b8xsEHMRPpfkOL4NE/nDWmTWNNEanJmKrWH1A=; b=eLzFTYDSP9Xt/uW/xYpmQJc9njy9frFxRvyAoBbPN0A8IYYedeepOitOOPd/PFQU7+ tGU6rvD2oC2antxm/WYwz8WboLW9LWFsum0XXtnYVV+/UIJYRsxZ++AB4zhk8iGo21IO kwr7sbvmw6MQ4H/0H7JS6wQG/c4Ky/TlssyzDlDb1xOZrAKm6d1x9DSVTy891wWo0/gm uVNAxp7zfRsO6JtMJSrBkv1RDMJlZjZvOS2gyDmoi+liQc/K68P8w9YnDK2cOnFjgelb s3/JcCCF2xsw8RH8ealsFmQVwIs9CkLGJdaYVslculiZHy1tLQDYOxmoqeBhtLE7oCOw Bf5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724250413; x=1724855213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BXdIh8b8xsEHMRPpfkOL4NE/nDWmTWNNEanJmKrWH1A=; b=Ppp6q5/5U3cU5qQfrCdT+TwQQkxIUapRQ7Kf3FIMEYmHAHpawiwYiXat18JfrZbReH /ux0Y3VmuQ8BjxQE3iBXeskQIFwaKuop0eWuzPLJfC3BYDKaDi81vJ8uTK0Z1EpIhpJI Cab+90Ha5aTjzYCbdxmBu2/pfny4HQ5hJbCOM7N7RVedmqTqbdV2OpcEuVa9n5E0TAEE KIAaQGobEdZVPmsqFr2XkMeE7u5M/zI+zaFYQO5I75AHfUKBssh8GLM/Ge26avnGS2XK 7XE7C7b1DzeJGnhFrvOfavH/73yq3yV5L3ewG+q7f0TquCtd6wXmi/E4pCverygSjm52 PR4A== X-Forwarded-Encrypted: i=1; AJvYcCUynwnLkZPIw7r3GuZ1TQcStBkwlVCYT6/CEyoBKD5jG31rcDBgDhNNDCkqndYfTQgrxnc=@vger.kernel.org X-Gm-Message-State: AOJu0YzkIuDG63O6pys6Fh9VWu3qlWBf0TgTGADzDdjXCinwZVgFn9sv w0Jrk98hcofRAU/S+47X1XLPWoA7Jtd40W3YmBtZgdd7Bk1sK625touLvmsMZzs= X-Google-Smtp-Source: AGHT+IE88JXO2twpmq32Cb9MW3e8dGHHyuJR6n2yRh6Jgp4wKRdFEtp+8UEdL8Pnee5IeiPEJWvqBg== X-Received: by 2002:a05:600c:310d:b0:426:6ed5:fcb with SMTP id 5b1f17b1804b1-42abd113c18mr26021405e9.4.1724250412671; Wed, 21 Aug 2024 07:26:52 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abebc34ddsm28646765e9.0.2024.08.21.07.26.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 07:26:52 -0700 (PDT) From: Anup Patel To: Will Deacon , julien.thierry.kdev@gmail.com, maz@kernel.org Cc: Paolo Bonzini , Atish Patra , Andrew Jones , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Anup Patel Subject: [kvmtool PATCH v3 3/4] riscv: Set SBI_SUCCESS on successful DBCN call Date: Wed, 21 Aug 2024 19:56:09 +0530 Message-Id: <20240821142610.3297483-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821142610.3297483-1-apatel@ventanamicro.com> References: <20240821142610.3297483-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andrew Jones Ensure we explicitly set SBI_SUCCESS on a successful SBI calls since KVM will not initialize it to zero for us. Only DBCN was neglecting to do so. Fixes: 4ddaa4249e0c ("riscv: Handle SBI DBCN calls from Guest/VM") Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- riscv/kvm-cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/riscv/kvm-cpu.c b/riscv/kvm-cpu.c index ae87848..0c171da 100644 --- a/riscv/kvm-cpu.c +++ b/riscv/kvm-cpu.c @@ -162,6 +162,7 @@ static bool kvm_cpu_riscv_sbi(struct kvm_cpu *vcpu) switch (vcpu->kvm_run->riscv_sbi.function_id) { case SBI_EXT_DBCN_CONSOLE_WRITE: case SBI_EXT_DBCN_CONSOLE_READ: + vcpu->kvm_run->riscv_sbi.ret[0] = SBI_SUCCESS; addr = vcpu->kvm_run->riscv_sbi.args[1]; #if __riscv_xlen == 32 addr |= (u64)vcpu->kvm_run->riscv_sbi.args[2] << 32; From patchwork Wed Aug 21 14:26:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13771683 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD6C21AD5F4 for ; Wed, 21 Aug 2024 14:27:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724250422; cv=none; b=jA8I8TGM/Pe9Q3bvZGyqFdbYhg5nEvShpCRrvj1xSsAWZPJHOmmn6kXLFRs1QYPCou4AbDJiZTvh4PwyQf2M3MxNkrwdk4ICgsyNgO2fKSpt62eWK1TvbzswcgHGX6XhRO6/vSzZLii0N4OESkYbtYm439d/lJm2pDSgdjdQh4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724250422; c=relaxed/simple; bh=IONQ9K+ncgBQnOswyimKlfv7KszvEvtd3KO+g7AOqXA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZCrk0srsn2qt4KrGMgQAyrvOoYJNXYx2v8UD/WGn+DwQmpSnxulqmtCLDfEXDk6UW4itBpLLcChGbH6tABnTyyPPFa3V6tYHvpEWgoen7X73IUMuFQQRTtighL9rkubNymAOe0mBO3YO63Yl60FQEfAKWdpj1M46+wQ3JyIR3Yo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=dRyajogO; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="dRyajogO" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3719753d365so3893658f8f.2 for ; Wed, 21 Aug 2024 07:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1724250419; x=1724855219; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5KqTGxW8AKVPvkiuwUCASJeIM7PQDb/Zh6a+fYZvgHw=; b=dRyajogOoxiecOQLLJvLbFzH4IVNO+VSsyvoag2qcWXx8YXa2DHkoPjms2QGsvlbfC gROBLTQqxR0e+6bK0GHWuFBYN5hg2uWUO6J/7qKgg8HJJzlhz4u7Y5uRmkNK3D7SJBjP gnx2+cc3EyUv7ibiITaDV6buJAiCb+yEPOg8PEOEHpsQGCc9Yh30TraOCaBbzBMQM/dZ IKSURhTsFzE41XNQ27eAkgK1MF2h8qqoXaglqeKvSy8GZE/ZDlRZ92peXP+U09GeH0aG QP9DezvhLL8/BST+oIIri0706kSm6JjFea1GspaW0r3OTAfmn8a3dZAvcZAttktkYX3k poYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724250419; x=1724855219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5KqTGxW8AKVPvkiuwUCASJeIM7PQDb/Zh6a+fYZvgHw=; b=CnDkwr7y+Qz8culkdwzmJtEc6ufyeK54m2ZuMYzxVko31SJvFhpME+2HBkQnBCLzlO pyhmwaqYci/VqVjjgK8NSKIs1GPOhzyBIsA2PBLh+knUSa2XnxUMi4FGZzrKDthfpbez 36RZ0F8F2GnIfPL/tF4T3LEq1Mh96GBrIf8+VHhTeqCcmgm81UD8zXNwL4NqliyfoM4D zmMEAT9/KF2OBXtTnhMUWMg6IMi1V2TJwh0RRKPMM+l2L7ojeGrjuSwRfLnTskOkK5Ug Wj/0/nCM8OLBcA+8gI5hY+7jqj0Axe/OVYU545YoqvOREApgwkW5YIo2XqXksR170IL+ 90YA== X-Forwarded-Encrypted: i=1; AJvYcCXJ3boP4AsQyx+yW1r6Ct6I9uRUEGQLmtapPs+W1p1+s/0cSR0GNL3lLfAgTLfv/j/Kob0=@vger.kernel.org X-Gm-Message-State: AOJu0YxVIHp8cXorIhvf9pp68cCWTAlMOV0Nr3FF9tKyPiTpUP+UTJhs XvnATx/Zl/Mzs27VuuyKUTW8I0iksJKoNEp3V3Xr5EroYqVGnn0kHDZ8OtrpQJk= X-Google-Smtp-Source: AGHT+IGafRGb247lD1GrwccfwBXd98zL9sW8f4ol63M7LSb6wWS+TrhwVQYhVrUkyGsLrvYd0XQeKw== X-Received: by 2002:a5d:4c51:0:b0:368:2f01:307a with SMTP id ffacd0b85a97d-372fd70f4e4mr1778474f8f.46.1724250418743; Wed, 21 Aug 2024 07:26:58 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42abebc34ddsm28646765e9.0.2024.08.21.07.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 07:26:58 -0700 (PDT) From: Anup Patel To: Will Deacon , julien.thierry.kdev@gmail.com, maz@kernel.org Cc: Paolo Bonzini , Atish Patra , Andrew Jones , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, Anup Patel Subject: [kvmtool PATCH v3 4/4] riscv: Correct number of hart bits Date: Wed, 21 Aug 2024 19:56:10 +0530 Message-Id: <20240821142610.3297483-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240821142610.3297483-1-apatel@ventanamicro.com> References: <20240821142610.3297483-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Andrew Jones The number of hart bits should be obtained from the highest hart ID, not the number of harts. For example, if a guest has 2 harts, then the number of bits should be fls(1) == 1. Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- riscv/aia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv/aia.c b/riscv/aia.c index fe9399a..21d9704 100644 --- a/riscv/aia.c +++ b/riscv/aia.c @@ -164,7 +164,7 @@ static int aia__init(struct kvm *kvm) ret = ioctl(aia_fd, KVM_SET_DEVICE_ATTR, &aia_nr_sources_attr); if (ret) return ret; - aia_hart_bits = fls_long(kvm->nrcpus); + aia_hart_bits = fls_long(kvm->nrcpus - 1); ret = ioctl(aia_fd, KVM_SET_DEVICE_ATTR, &aia_hart_bits_attr); if (ret) return ret;