From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4827C433DB for ; Wed, 23 Dec 2020 03:31:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FF9D2070B for ; Wed, 23 Dec 2020 03:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727949AbgLWDb2 convert rfc822-to-8bit (ORCPT ); Tue, 22 Dec 2020 22:31:28 -0500 Received: from szxga08-in.huawei.com ([45.249.212.255]:2345 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725852AbgLWDb2 (ORCPT ); Tue, 22 Dec 2020 22:31:28 -0500 Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4D0zGN2jMkz13XWq; Wed, 23 Dec 2020 11:29:32 +0800 (CST) Received: from dggpemm000004.china.huawei.com (7.185.36.154) by DGGEMM403-HUB.china.huawei.com (10.3.20.211) with Microsoft SMTP Server (TLS) id 14.3.498.0; Wed, 23 Dec 2020 11:30:43 +0800 Received: from dggpemm000001.china.huawei.com (7.185.36.245) by dggpemm000004.china.huawei.com (7.185.36.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Wed, 23 Dec 2020 11:30:44 +0800 Received: from dggpemm000001.china.huawei.com ([7.185.36.245]) by dggpemm000001.china.huawei.com ([7.185.36.245]) with mapi id 15.01.1913.007; Wed, 23 Dec 2020 11:30:44 +0800 From: Jiangyifei To: Anup Patel , Palmer Dabbelt , Palmer Dabbelt , Paul Walmsley , Albert Ou , Paolo Bonzini CC: Alexander Graf , Atish Patra , Alistair Francis , Damien Le Moal , Anup Patel , "kvm@vger.kernel.org" , "kvm-riscv@lists.infradead.org" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Daniel Lezcano Subject: RE: [PATCH v15 12/17] RISC-V: KVM: Add timer functionality Thread-Topic: [PATCH v15 12/17] RISC-V: KVM: Add timer functionality Thread-Index: AQHWtoyLg56Gu0NX0EGJJ8nRAPiOhKoERjWw Date: Wed, 23 Dec 2020 03:30:43 +0000 Message-ID: References: <20201109113240.3733496-1-anup.patel@wdc.com> <20201109113240.3733496-13-anup.patel@wdc.com> In-Reply-To: <20201109113240.3733496-13-anup.patel@wdc.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.186.236] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Anup Patel [mailto:anup.patel@wdc.com] > Sent: Monday, November 9, 2020 7:33 PM > To: Palmer Dabbelt ; Palmer Dabbelt > ; Paul Walmsley ; > Albert Ou ; Paolo Bonzini > Cc: Alexander Graf ; Atish Patra ; > Alistair Francis ; Damien Le Moal > ; Anup Patel ; > kvm@vger.kernel.org; kvm-riscv@lists.infradead.org; > linux-riscv@lists.infradead.org; linux-kernel@vger.kernel.org; Anup Patel > ; Daniel Lezcano > Subject: [PATCH v15 12/17] RISC-V: KVM: Add timer functionality > > From: Atish Patra > > The RISC-V hypervisor specification doesn't have any virtual timer feature. > > Due to this, the guest VCPU timer will be programmed via SBI calls. > The host will use a separate hrtimer event for each guest VCPU to provide > timer functionality. We inject a virtual timer interrupt to the guest VCPU > whenever the guest VCPU hrtimer event expires. > > This patch adds guest VCPU timer implementation along with ONE_REG > interface to access VCPU timer state from user space. > > Signed-off-by: Atish Patra > Signed-off-by: Anup Patel > Acked-by: Paolo Bonzini > Reviewed-by: Paolo Bonzini > Acked-by: Daniel Lezcano > --- > arch/riscv/include/asm/kvm_host.h | 7 + > arch/riscv/include/asm/kvm_vcpu_timer.h | 44 +++++ > arch/riscv/include/uapi/asm/kvm.h | 17 ++ > arch/riscv/kvm/Makefile | 2 +- > arch/riscv/kvm/vcpu.c | 14 ++ > arch/riscv/kvm/vcpu_timer.c | 225 > ++++++++++++++++++++++++ > arch/riscv/kvm/vm.c | 2 +- > drivers/clocksource/timer-riscv.c | 8 + > include/clocksource/timer-riscv.h | 16 ++ > 9 files changed, 333 insertions(+), 2 deletions(-) create mode 100644 > arch/riscv/include/asm/kvm_vcpu_timer.h > create mode 100644 arch/riscv/kvm/vcpu_timer.c create mode 100644 > include/clocksource/timer-riscv.h > > diff --git a/arch/riscv/include/asm/kvm_host.h > b/arch/riscv/include/asm/kvm_host.h > index 64311b262ee1..4daffc93f36a 100644 > --- a/arch/riscv/include/asm/kvm_host.h > +++ b/arch/riscv/include/asm/kvm_host.h > @@ -12,6 +12,7 @@ > #include > #include > #include > +#include > > #ifdef CONFIG_64BIT > #define KVM_MAX_VCPUS (1U << 16) > @@ -66,6 +67,9 @@ struct kvm_arch { > /* stage2 page table */ > pgd_t *pgd; > phys_addr_t pgd_phys; > + > + /* Guest Timer */ > + struct kvm_guest_timer timer; > }; > ... > diff --git a/arch/riscv/include/uapi/asm/kvm.h > b/arch/riscv/include/uapi/asm/kvm.h > index f7e9dc388d54..00196a13d743 100644 > --- a/arch/riscv/include/uapi/asm/kvm.h > +++ b/arch/riscv/include/uapi/asm/kvm.h > @@ -74,6 +74,18 @@ struct kvm_riscv_csr { > unsigned long scounteren; > }; > > +/* TIMER registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ > struct > +kvm_riscv_timer { > + u64 frequency; > + u64 time; > + u64 compare; > + u64 state; > +}; > + Hi, There are some building errors when we build kernel by using allmodconfig. The commands are as follow: $ make allmodconfig ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- $ make -j64 ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- The following error occurs: [stdout] usr/include/Makefile:108: recipe for target 'usr/include/asm/kvm.hdrtest' failed [stderr] ./usr/include/asm/kvm.h:79:2: error: unknown type name 'u64' [stderr] u64 frequency; [stderr] ^~~ [stderr] ./usr/include/asm/kvm.h:80:2: error: unknown type name 'u64' [stderr] u64 time; [stderr] ^~~ [stderr] ./usr/include/asm/kvm.h:81:2: error: unknown type name 'u64' [stderr] u64 compare; [stderr] ^~~ [stderr] ./usr/include/asm/kvm.h:82:2: error: unknown type name 'u64' [stderr] u64 state; [stderr] ^~~ [stderr] make[2]: *** [usr/include/asm/kvm.hdrtest] Error 1 Is it better to change u64 to __u64? Regards, Yifei