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=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 193DFC433E0 for ; Wed, 27 May 2020 02:55:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E712E2075F for ; Wed, 27 May 2020 02:55:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A9utoaO4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728251AbgE0CzW (ORCPT ); Tue, 26 May 2020 22:55:22 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40621 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725893AbgE0CzW (ORCPT ); Tue, 26 May 2020 22:55:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590548120; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l4K9Ld8nvFhhrcUkF46+uYVzHz+spBxIeBhQGnUCsLs=; b=A9utoaO4xJ1KlkScQ/p6asaAvyHOcr1eEy8yWJrqj0SlOFf2iGGYdiVk3mvjQIRZRuAy27 rACSvKxFb+44EeQIXR3UTthEUV7KMTYegfZrFlaC0h8Zs9xSxwnOSPGxRk7QnObFmjailZ ZtsA4wNaDOqvYN5IvEctMxB5J99MMt0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-vg8k3xqlP2uyYE5pKH1NJA-1; Tue, 26 May 2020 22:55:15 -0400 X-MC-Unique: vg8k3xqlP2uyYE5pKH1NJA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B61EC10753FB; Wed, 27 May 2020 02:55:13 +0000 (UTC) Received: from localhost.localdomain (vpn2-54-130.bne.redhat.com [10.64.54.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2852E5D9E7; Wed, 27 May 2020 02:55:06 +0000 (UTC) Reply-To: Gavin Shan Subject: Re: [PATCH RFCv2 4/9] kvm/arm64: Detach ESR operator from vCPU struct To: Mark Rutland Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, maz@kernel.org, will@kernel.org, catalin.marinas@arm.com, james.morse@arm.com, suzuki.poulose@arm.com, drjones@redhat.com, eric.auger@redhat.com, aarcange@redhat.com, shan.gavin@gmail.com References: <20200508032919.52147-1-gshan@redhat.com> <20200508032919.52147-5-gshan@redhat.com> <20200526105154.GD1363@C02TD0UTHF1T.local> From: Gavin Shan Message-ID: <4cda1e43-8f96-4e48-2642-39a5545905c0@redhat.com> Date: Wed, 27 May 2020 12:55:04 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <20200526105154.GD1363@C02TD0UTHF1T.local> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, On 5/26/20 8:51 PM, Mark Rutland wrote: > On Fri, May 08, 2020 at 01:29:14PM +1000, Gavin Shan wrote: >> There are a set of inline functions defined in kvm_emulate.h. Those >> functions reads ESR from vCPU fault information struct and then operate >> on it. So it's tied with vCPU fault information and vCPU struct. It >> limits their usage scope. >> >> This detaches these functions from the vCPU struct. With this, the >> caller has flexibility on where the ESR is read. It shouldn't cause >> any functional changes. >> >> Signed-off-by: Gavin Shan >> --- >> arch/arm64/include/asm/kvm_emulate.h | 83 +++++++++++------------- >> arch/arm64/kvm/handle_exit.c | 20 ++++-- >> arch/arm64/kvm/hyp/switch.c | 24 ++++--- >> arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 7 +- >> arch/arm64/kvm/inject_fault.c | 4 +- >> arch/arm64/kvm/sys_regs.c | 12 ++-- >> virt/kvm/arm/arm.c | 4 +- >> virt/kvm/arm/hyp/aarch32.c | 2 +- >> virt/kvm/arm/hyp/vgic-v3-sr.c | 5 +- >> virt/kvm/arm/mmio.c | 27 ++++---- >> virt/kvm/arm/mmu.c | 22 ++++--- >> 11 files changed, 112 insertions(+), 98 deletions(-) >> >> diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h >> index bd1a69e7c104..2873bf6dc85e 100644 >> --- a/arch/arm64/include/asm/kvm_emulate.h >> +++ b/arch/arm64/include/asm/kvm_emulate.h >> @@ -270,10 +270,8 @@ static __always_inline u32 kvm_vcpu_get_esr(const struct kvm_vcpu *vcpu) >> return vcpu->arch.fault.esr_el2; >> } >> >> -static __always_inline int kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu) >> +static __always_inline int kvm_vcpu_get_condition(u32 esr) > > Given the `vcpu` argument has been removed, it's odd to keep `vcpu` in the > name, rather than `esr`. > > e.g. this would make more sense as something like esr_get_condition(). > > ... and if we did something like that, we could move most of the > extraction functions into , and share them with non-KVM code. > > Otherwise, do you need to extract all of these for your use-case, or do > you only need a few of the helpers? If you only need a few, it might be > better to only factor those out for now, and keep the existing API in > place with wrappers, e.g. have: > > | esr_get_condition(u32 esr) { > | ... > | } > | > | kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu) > | { > | return esr_get_condition(kvm_vcpu_get_esr(vcpu)); > | } > Sure, I'll follow approach#1, to move these helper functions to asm/esr.h and with "vcpu" dropped in their names. I don't think it makes sense to maintain two sets of helper functions for the simple logic. So the helper function will be called where they should be, as below: esr_get_condition(u32 esr) { ... } bool __hyp_text kvm_condition_valid32(const struct kvm_vcpu *vcpu) { int cond = esr_get_condition(kvm_vcpu_get_esr(vcpu)); : } Thanks, Gavin 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=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 2B483C433E1 for ; Wed, 27 May 2020 07:18:44 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id C9068208B8 for ; Wed, 27 May 2020 07:18:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ifrTjFg/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9068208B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 5FE674B1D1; Wed, 27 May 2020 03:18:43 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cmvejE0gaZ22; Wed, 27 May 2020 03:18:42 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 8D0264B20A; Wed, 27 May 2020 03:18:40 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 69E994B173 for ; Tue, 26 May 2020 22:55:20 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cGGs-uNO+z8H for ; Tue, 26 May 2020 22:55:19 -0400 (EDT) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 77E1F4B14B for ; Tue, 26 May 2020 22:55:19 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590548119; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l4K9Ld8nvFhhrcUkF46+uYVzHz+spBxIeBhQGnUCsLs=; b=ifrTjFg/lYKP850PBruJP5HOdVr23YW4PXY/JiCW4ETN9jdneMScnnlHbjmY4u7cxIKK9l 92TvwyZK92z5lc1E2ZEl/dwAfZwNkwYWfWSLNvrSva0FhDUIZLIK//KHtOpkiXPwNaDEUx xUh9erK3+ZwPLO2MKMxM7p4s/fPb1Cs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-vg8k3xqlP2uyYE5pKH1NJA-1; Tue, 26 May 2020 22:55:15 -0400 X-MC-Unique: vg8k3xqlP2uyYE5pKH1NJA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B61EC10753FB; Wed, 27 May 2020 02:55:13 +0000 (UTC) Received: from localhost.localdomain (vpn2-54-130.bne.redhat.com [10.64.54.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2852E5D9E7; Wed, 27 May 2020 02:55:06 +0000 (UTC) Subject: Re: [PATCH RFCv2 4/9] kvm/arm64: Detach ESR operator from vCPU struct To: Mark Rutland References: <20200508032919.52147-1-gshan@redhat.com> <20200508032919.52147-5-gshan@redhat.com> <20200526105154.GD1363@C02TD0UTHF1T.local> From: Gavin Shan Message-ID: <4cda1e43-8f96-4e48-2642-39a5545905c0@redhat.com> Date: Wed, 27 May 2020 12:55:04 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <20200526105154.GD1363@C02TD0UTHF1T.local> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mailman-Approved-At: Wed, 27 May 2020 03:18:39 -0400 Cc: catalin.marinas@arm.com, linux-kernel@vger.kernel.org, shan.gavin@gmail.com, maz@kernel.org, will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Gavin Shan List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Hi Mark, On 5/26/20 8:51 PM, Mark Rutland wrote: > On Fri, May 08, 2020 at 01:29:14PM +1000, Gavin Shan wrote: >> There are a set of inline functions defined in kvm_emulate.h. Those >> functions reads ESR from vCPU fault information struct and then operate >> on it. So it's tied with vCPU fault information and vCPU struct. It >> limits their usage scope. >> >> This detaches these functions from the vCPU struct. With this, the >> caller has flexibility on where the ESR is read. It shouldn't cause >> any functional changes. >> >> Signed-off-by: Gavin Shan >> --- >> arch/arm64/include/asm/kvm_emulate.h | 83 +++++++++++------------- >> arch/arm64/kvm/handle_exit.c | 20 ++++-- >> arch/arm64/kvm/hyp/switch.c | 24 ++++--- >> arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 7 +- >> arch/arm64/kvm/inject_fault.c | 4 +- >> arch/arm64/kvm/sys_regs.c | 12 ++-- >> virt/kvm/arm/arm.c | 4 +- >> virt/kvm/arm/hyp/aarch32.c | 2 +- >> virt/kvm/arm/hyp/vgic-v3-sr.c | 5 +- >> virt/kvm/arm/mmio.c | 27 ++++---- >> virt/kvm/arm/mmu.c | 22 ++++--- >> 11 files changed, 112 insertions(+), 98 deletions(-) >> >> diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h >> index bd1a69e7c104..2873bf6dc85e 100644 >> --- a/arch/arm64/include/asm/kvm_emulate.h >> +++ b/arch/arm64/include/asm/kvm_emulate.h >> @@ -270,10 +270,8 @@ static __always_inline u32 kvm_vcpu_get_esr(const struct kvm_vcpu *vcpu) >> return vcpu->arch.fault.esr_el2; >> } >> >> -static __always_inline int kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu) >> +static __always_inline int kvm_vcpu_get_condition(u32 esr) > > Given the `vcpu` argument has been removed, it's odd to keep `vcpu` in the > name, rather than `esr`. > > e.g. this would make more sense as something like esr_get_condition(). > > ... and if we did something like that, we could move most of the > extraction functions into , and share them with non-KVM code. > > Otherwise, do you need to extract all of these for your use-case, or do > you only need a few of the helpers? If you only need a few, it might be > better to only factor those out for now, and keep the existing API in > place with wrappers, e.g. have: > > | esr_get_condition(u32 esr) { > | ... > | } > | > | kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu) > | { > | return esr_get_condition(kvm_vcpu_get_esr(vcpu)); > | } > Sure, I'll follow approach#1, to move these helper functions to asm/esr.h and with "vcpu" dropped in their names. I don't think it makes sense to maintain two sets of helper functions for the simple logic. So the helper function will be called where they should be, as below: esr_get_condition(u32 esr) { ... } bool __hyp_text kvm_condition_valid32(const struct kvm_vcpu *vcpu) { int cond = esr_get_condition(kvm_vcpu_get_esr(vcpu)); : } Thanks, Gavin _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 2E887C433E0 for ; Wed, 27 May 2020 02:55:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 03E062075F for ; Wed, 27 May 2020 02:55:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KeXjGbM5"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A9utoaO4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03E062075F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:Reply-To:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JVfxe7NHAwz6TkQc9yJhBoh6Bwj/CdOl7HcXkhtmAZM=; b=KeXjGbM5UrJXIe EjMzwOqtnW9ilbWpf9Jc2Qz4Ho0Fla7Z821QUcpKx/pYXsHMlELBE0YrJMfm0m5mUePqwvkipV7DP Qliin5yA6WWgNn5ZhRH9uM2eE7SSZEK3yb/iZPphx/oTJaHlGz/72eM5rNIg71ufI4epPlLOBFyxO IalsUMFkVw4fIDrK63ECQ6j+YUkL8nV3fzf2qRLBcPRgOhtJ2l8FjhU/BFW0hsTb97nZNe3UJ2Kn4 DsSvFveLG6Tt5eAptDqBKBPWH0ppfBVWzL4/rYRkFcl8croXRgYRPSPktsA3OOIm/t6dns1JrfwWo Oa1UKvC1Nxv51BC56fwA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jdmE0-00040m-FR; Wed, 27 May 2020 02:55:24 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jdmDx-00040P-JP for linux-arm-kernel@lists.infradead.org; Wed, 27 May 2020 02:55:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590548120; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l4K9Ld8nvFhhrcUkF46+uYVzHz+spBxIeBhQGnUCsLs=; b=A9utoaO4xJ1KlkScQ/p6asaAvyHOcr1eEy8yWJrqj0SlOFf2iGGYdiVk3mvjQIRZRuAy27 rACSvKxFb+44EeQIXR3UTthEUV7KMTYegfZrFlaC0h8Zs9xSxwnOSPGxRk7QnObFmjailZ ZtsA4wNaDOqvYN5IvEctMxB5J99MMt0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-301-vg8k3xqlP2uyYE5pKH1NJA-1; Tue, 26 May 2020 22:55:15 -0400 X-MC-Unique: vg8k3xqlP2uyYE5pKH1NJA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B61EC10753FB; Wed, 27 May 2020 02:55:13 +0000 (UTC) Received: from localhost.localdomain (vpn2-54-130.bne.redhat.com [10.64.54.130]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2852E5D9E7; Wed, 27 May 2020 02:55:06 +0000 (UTC) Subject: Re: [PATCH RFCv2 4/9] kvm/arm64: Detach ESR operator from vCPU struct To: Mark Rutland References: <20200508032919.52147-1-gshan@redhat.com> <20200508032919.52147-5-gshan@redhat.com> <20200526105154.GD1363@C02TD0UTHF1T.local> From: Gavin Shan Message-ID: <4cda1e43-8f96-4e48-2642-39a5545905c0@redhat.com> Date: Wed, 27 May 2020 12:55:04 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <20200526105154.GD1363@C02TD0UTHF1T.local> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200526_195521_719871_D2F5FF73 X-CRM114-Status: GOOD ( 21.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Gavin Shan Cc: aarcange@redhat.com, drjones@redhat.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, eric.auger@redhat.com, james.morse@arm.com, shan.gavin@gmail.com, maz@kernel.org, will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Mark, On 5/26/20 8:51 PM, Mark Rutland wrote: > On Fri, May 08, 2020 at 01:29:14PM +1000, Gavin Shan wrote: >> There are a set of inline functions defined in kvm_emulate.h. Those >> functions reads ESR from vCPU fault information struct and then operate >> on it. So it's tied with vCPU fault information and vCPU struct. It >> limits their usage scope. >> >> This detaches these functions from the vCPU struct. With this, the >> caller has flexibility on where the ESR is read. It shouldn't cause >> any functional changes. >> >> Signed-off-by: Gavin Shan >> --- >> arch/arm64/include/asm/kvm_emulate.h | 83 +++++++++++------------- >> arch/arm64/kvm/handle_exit.c | 20 ++++-- >> arch/arm64/kvm/hyp/switch.c | 24 ++++--- >> arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 7 +- >> arch/arm64/kvm/inject_fault.c | 4 +- >> arch/arm64/kvm/sys_regs.c | 12 ++-- >> virt/kvm/arm/arm.c | 4 +- >> virt/kvm/arm/hyp/aarch32.c | 2 +- >> virt/kvm/arm/hyp/vgic-v3-sr.c | 5 +- >> virt/kvm/arm/mmio.c | 27 ++++---- >> virt/kvm/arm/mmu.c | 22 ++++--- >> 11 files changed, 112 insertions(+), 98 deletions(-) >> >> diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h >> index bd1a69e7c104..2873bf6dc85e 100644 >> --- a/arch/arm64/include/asm/kvm_emulate.h >> +++ b/arch/arm64/include/asm/kvm_emulate.h >> @@ -270,10 +270,8 @@ static __always_inline u32 kvm_vcpu_get_esr(const struct kvm_vcpu *vcpu) >> return vcpu->arch.fault.esr_el2; >> } >> >> -static __always_inline int kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu) >> +static __always_inline int kvm_vcpu_get_condition(u32 esr) > > Given the `vcpu` argument has been removed, it's odd to keep `vcpu` in the > name, rather than `esr`. > > e.g. this would make more sense as something like esr_get_condition(). > > ... and if we did something like that, we could move most of the > extraction functions into , and share them with non-KVM code. > > Otherwise, do you need to extract all of these for your use-case, or do > you only need a few of the helpers? If you only need a few, it might be > better to only factor those out for now, and keep the existing API in > place with wrappers, e.g. have: > > | esr_get_condition(u32 esr) { > | ... > | } > | > | kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu) > | { > | return esr_get_condition(kvm_vcpu_get_esr(vcpu)); > | } > Sure, I'll follow approach#1, to move these helper functions to asm/esr.h and with "vcpu" dropped in their names. I don't think it makes sense to maintain two sets of helper functions for the simple logic. So the helper function will be called where they should be, as below: esr_get_condition(u32 esr) { ... } bool __hyp_text kvm_condition_valid32(const struct kvm_vcpu *vcpu) { int cond = esr_get_condition(kvm_vcpu_get_esr(vcpu)); : } Thanks, Gavin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel