From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FF1A606A680 for ; Wed, 2 Dec 2026 14:12:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=e3E5ugsF; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=gypfvHxK DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=pAFgIL6USPbcoc7ld/2qGLYp/1sP1Q78LPz+2InAQGk=; b=e3E5ugsFQf2OLe 7QBDBUVpQYQuzvFtkkR3oJZRAQPs0y/BfrnVF7s7sPb2txAjFrZOjgehG1NsEBAYpuArlke72TK77 xKk6fU2+avuHdmzLkdyLwC1wI3AxMy2ApEZlvLH3tEylejMwuoLpFv59EPWAv/R4ccKV8iscUzBVa kqOmBIWzE4QqiMKIwCKEWdHbH0E8v0J+UfygJa4AA0ISzo74A4IdiI+uh8Lli413BW0zvta7gbBZ9 QH7JmD3431d1e7q+iqh9CX6Z08fp6FIwuKBGITm6ZB7eieQRZnQ5gbQNOsowzHWex5uSSoMRap4Of HL5e/fqUxURyLVopjKBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYl4Z-0000000Bh7v-37MA; Wed, 02 Dec 2026 14:12:39 +0000 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYl4T-0000000Bh5z-2Iy9 for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 14:12:38 +0000 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2AM3vO2795044; Wed, 2 Dec 2026 14:12:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=pAFgIL 6USPbcoc7ld/2qGLYp/1sP1Q78LPz+2InAQGk=; b=gypfvHxKkMT+cgd2A7bE99 LjTVZkk8KQhQrBIv63jsW4Knbgae0HrazbUC3VHIoobXeznLUUMtnP6J/2FuzLl6 DtSrfhtZTJVao+KCIbjQ01HkyLiz5ZRlfDV0xeLDR2aXzQsHqID6A6Jx/aKt/q0v NzLxjP/+CjpO6YqSfsR8xQ28V60qmepAiN2EjaJUiaOPqyqJ3dW8qw99hWP62k6f kFJUMA6E1rKB1v1hDPGJp7UvM94rnD4KvY1p/PZXodFGf0xcoYF8jtj3dfC8JpNK 5XlzwZP2hxBK6/+YWkK048boJzVNlfBa/1ZnROSZd0bo9K4MzLlQHsUtfiI2oUXw == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pmta4dv-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 14:12:07 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2BcqKw2682952; Wed, 2 Dec 2026 14:12:07 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4j9ujnndsx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 02 Dec 2026 14:12:06 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B2EC3pM30868152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 2 Dec 2026 14:12:03 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3E75820040; Wed, 2 Dec 2026 14:12:03 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DA5E92004B; Wed, 2 Dec 2026 14:12:02 +0000 (GMT) Received: from a46lp73.lnxne.boe (unknown [9.87.84.240]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 2 Dec 2026 14:12:02 +0000 (GMT) From: Steffen Eiden Date: Wed, 02 Dec 2026 15:11:39 +0100 Subject: [PATCH 01/12] arm64: Prepare for sharing with s390 X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-smccc-v1-1-48340e2737b6@linux.ibm.com> References: <20261202-smccc-v1-0-48340e2737b6@linux.ibm.com> In-Reply-To: <20261202-smccc-v1-0-48340e2737b6@linux.ibm.com> To: Marc Zyngier , Oliver Upton , Fuad Tabba , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , Andreas Grapentin , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Sven Schnelle , Friedrich Welter , Gautam Gala , Hariharan Mari , Hendrik Brueckner , Nico Boehr , Ulrich Weigand , Arnd Bergmann , Paolo Bonzini Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, Steffen Eiden X-Mailer: b4 0.14.3 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: mJ6HmVsJANzQ771zehuxaLoJJtckwb9a X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA1NiBTYWx0ZWRfXwknJFzoEW7gD cfP3i/bPOCQbQ/z7Rikv7QyQd1r8rUv6OKAbkj1nvKv83FmvSImhFtZqyks7QoXY5qi+KNn1ifo 98IdGUutSlDXb7rzcfJXG/RN4saTgqUSQNLSS14MwhriWAbe0ftVDgfvjH57fDH6Ie4en/6wJn1 tW84izi7OhziWJs8XiDoPOZzmc4gA8ACqZqVDQmMNJWOfMhVjLYWFGAnS2txRC5kH7d4OGKxR2G LbuyS9YRvl1Tq8MZAdNuXhs378UkO18qLTyYwEEc03oA9Zlt7ldjeigrWdE40fthWz1j+5Y9sc2 51CKYX3sTBfWt371nCo/0Z2IYSX7Ln2GPmGay0LLKRsP4ZTkGhM/rCYUGjB+JvukmwIn6VB1YrS b5jkdDfMEMUR1k86DzyxgBw2A+a7j/fdesZJyH39187oDj7wtsNjNKXRRJRSGsGm7DBkTHriORh 8WG+E+TtfDMWL9/b9yg== X-Proofpoint-GUID: mJ6HmVsJANzQ771zehuxaLoJJtckwb9a X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA1NiBTYWx0ZWRfX0jeMNP1zRgH7 6ueYCfVh99gG2HT8ks/eylN1UQ2oOer2FobVBJpPSJa1/KTqg4pR9+9VceIjop36v/P49v/bmlS XddN3xBRNcAJgftK6snZddg4L/J2WR8= X-Authority-Analysis: v=2.4 cv=U9cHnuru c=1 sm=1 tr=0 ts=6b102737 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=jP45ErzVrDJu4l26dt8A:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-02_02,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 priorityscore=1501 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020056 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_061233_677812_A87079B2 X-CRM114-Status: GOOD ( 22.40 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Add s390 guards for arm headers which reside in include/kvm. This allows s390 to use headers placed in its arch include/arm64/ . Move vcpu_can_run to a more convenient location such that it can be shared without adding another shared section. Move functions in arch_timer.c to more convenient locations such that the required functionality can be shared with just two shared regions instead of seven. Signed-off-by: Steffen Eiden --- arch/arm64/include/asm/kvm_host.h | 4 +- arch/arm64/kvm/arch_timer.c | 87 ++++++++++++++++++++------------------- arch/arm64/kvm/arm.c | 10 ++--- include/kvm/arm_hypercalls.h | 3 ++ include/kvm/arm_psci.h | 3 ++ 5 files changed, 57 insertions(+), 50 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 3242bdf1acf8..5072de2ac8ce 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -396,6 +396,8 @@ static inline u16 kvm_mpidr_index(struct kvm_mpidr_data *data, u64 mpidr) return index; } +struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr); + struct kvm_sysreg_masks; enum fgt_group_id { @@ -1444,8 +1446,6 @@ static inline bool kvm_arm_is_pvtime_enabled(struct kvm_vcpu_arch *vcpu_arch) return (vcpu_arch->steal.base != INVALID_GPA); } -struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr); - DECLARE_KVM_HYP_PER_CPU(struct kvm_host_data, kvm_host_data); /* diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index b2c5ba499aa5..2de8ce48a7a0 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -50,6 +50,7 @@ static u64 kvm_arm_timer_read(struct kvm_vcpu *vcpu, struct arch_timer_context *timer, enum kvm_arch_timer_regs treg); static bool kvm_arch_timer_get_input_level(int vintid); +static inline bool userspace_irqchip(struct kvm *kvm); static unsigned long kvm_arch_timer_get_irq_flags(void) { @@ -67,14 +68,6 @@ static const struct irq_ops arch_timer_irq_ops_vgic_v5 = { .set_direct_injection = vgic_v5_set_ppi_dvi, }; -static int nr_timers(struct kvm_vcpu *vcpu) -{ - if (!vcpu_has_nv(vcpu)) - return NR_KVM_EL0_TIMERS; - - return NR_KVM_TIMERS; -} - u32 timer_get_ctl(struct arch_timer_context *ctxt) { struct kvm_vcpu *vcpu = timer_context_to_vcpu(ctxt); @@ -191,22 +184,6 @@ void get_timer_map(struct kvm_vcpu *vcpu, struct timer_map *map) trace_kvm_get_timer_map(vcpu->vcpu_id, map); } -static inline bool userspace_irqchip(struct kvm *kvm) -{ - return unlikely(!irqchip_in_kernel(kvm)); -} - -static void soft_timer_start(struct hrtimer *hrt, u64 ns) -{ - hrtimer_start(hrt, ktime_add_ns(ktime_get(), ns), - HRTIMER_MODE_ABS_HARD); -} - -static void soft_timer_cancel(struct hrtimer *hrt) -{ - hrtimer_cancel(hrt); -} - static irqreturn_t kvm_arch_timer_handler(int irq, void *dev_id) { struct kvm_vcpu *vcpu = *(struct kvm_vcpu **)dev_id; @@ -257,11 +234,6 @@ static u64 kvm_counter_compute_delta(struct arch_timer_context *timer_ctx, return 0; } -static u64 kvm_timer_compute_delta(struct arch_timer_context *timer_ctx) -{ - return kvm_counter_compute_delta(timer_ctx, timer_get_cval(timer_ctx)); -} - static bool kvm_timer_enabled(struct arch_timer_context *timer_ctx) { WARN_ON(timer_ctx && timer_ctx->loaded); @@ -276,6 +248,35 @@ static bool vcpu_has_wfit_active(struct kvm_vcpu *vcpu) vcpu_get_flag(vcpu, IN_WFIT)); } +static int nr_timers(struct kvm_vcpu *vcpu) +{ + if (!vcpu_has_nv(vcpu)) + return NR_KVM_EL0_TIMERS; + + return NR_KVM_TIMERS; +} + +static inline bool userspace_irqchip(struct kvm *kvm) +{ + return unlikely(!irqchip_in_kernel(kvm)); +} + +static void soft_timer_start(struct hrtimer *hrt, u64 ns) +{ + hrtimer_start(hrt, ktime_add_ns(ktime_get(), ns), + HRTIMER_MODE_ABS_HARD); +} + +static void soft_timer_cancel(struct hrtimer *hrt) +{ + hrtimer_cancel(hrt); +} + +static u64 kvm_timer_compute_delta(struct arch_timer_context *timer_ctx) +{ + return kvm_counter_compute_delta(timer_ctx, timer_get_cval(timer_ctx)); +} + static u64 wfit_delay_ns(struct kvm_vcpu *vcpu) { u64 val = vcpu_get_reg(vcpu, kvm_vcpu_sys_get_rt(vcpu)); @@ -436,6 +437,20 @@ bool kvm_timer_update_run(struct kvm_vcpu *vcpu) return !!mask; } +static void kvm_timer_unblocking(struct kvm_vcpu *vcpu) +{ + struct arch_timer_cpu *timer = vcpu_timer(vcpu); + + soft_timer_cancel(&timer->bg_timer); +} + +void kvm_timer_vcpu_terminate(struct kvm_vcpu *vcpu) +{ + struct arch_timer_cpu *timer = vcpu_timer(vcpu); + + soft_timer_cancel(&timer->bg_timer); +} + static void kvm_timer_update_status(struct arch_timer_context *ctx, bool level) { /* @@ -612,13 +627,6 @@ static void kvm_timer_blocking(struct kvm_vcpu *vcpu) soft_timer_start(&timer->bg_timer, kvm_timer_earliest_exp(vcpu)); } -static void kvm_timer_unblocking(struct kvm_vcpu *vcpu) -{ - struct arch_timer_cpu *timer = vcpu_timer(vcpu); - - soft_timer_cancel(&timer->bg_timer); -} - static void timer_restore_state(struct arch_timer_context *ctx) { struct arch_timer_cpu *timer = vcpu_timer(timer_context_to_vcpu(ctx)); @@ -1520,13 +1528,6 @@ int __init kvm_timer_hyp_init(bool has_gic) return err; } -void kvm_timer_vcpu_terminate(struct kvm_vcpu *vcpu) -{ - struct arch_timer_cpu *timer = vcpu_timer(vcpu); - - soft_timer_cancel(&timer->bg_timer); -} - static bool timer_irqs_are_valid(struct kvm_vcpu *vcpu) { u32 ppis = 0; diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 4d44b638b7d3..0d4d4849564c 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -901,6 +901,11 @@ static bool kvm_arm_vcpu_suspended(struct kvm_vcpu *vcpu) return READ_ONCE(vcpu->arch.mp_state.mp_state) == KVM_MP_STATE_SUSPENDED; } +static bool vcpu_can_run(struct kvm_vcpu *vcpu) +{ + return !kvm_arm_vcpu_stopped(vcpu) && !atomic_read(&vcpu->arch.pause); +} + /* Only the guest's CPU_ON may start a vCPU EL2 holds powered off. */ bool kvm_pkvm_vcpu_is_powered_off(struct kvm_vcpu *vcpu) { @@ -953,11 +958,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, return ret; } -static bool vcpu_can_run(struct kvm_vcpu *vcpu) -{ - return !kvm_arm_vcpu_stopped(vcpu) && !atomic_read(&vcpu->arch.pause); -} - /** * kvm_arch_vcpu_runnable - determine if the vcpu can be scheduled * @v: The VCPU pointer diff --git a/include/kvm/arm_hypercalls.h b/include/kvm/arm_hypercalls.h index 2df152207ccd..5ce4c2d43f9a 100644 --- a/include/kvm/arm_hypercalls.h +++ b/include/kvm/arm_hypercalls.h @@ -4,7 +4,10 @@ #ifndef __KVM_ARM_HYPERCALLS_H #define __KVM_ARM_HYPERCALLS_H +/* s390 provides its own header view */ +#ifndef __s390__ #include +#endif // !__s390__ int kvm_smccc_call_handler(struct kvm_vcpu *vcpu); diff --git a/include/kvm/arm_psci.h b/include/kvm/arm_psci.h index 06c20612e9e7..f358ae19267b 100644 --- a/include/kvm/arm_psci.h +++ b/include/kvm/arm_psci.h @@ -10,7 +10,10 @@ #include #include +/* s390 provides its own header view */ +#ifndef __s390__ #include +#endif // !__s390__ #define KVM_ARM_PSCI_0_1 PSCI_VERSION(0, 1) #define KVM_ARM_PSCI_0_2 PSCI_VERSION(0, 2) -- 2.56.1