public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: Mihai Caraman <mihai.caraman@freescale.com>
Cc: <kvm-ppc@vger.kernel.org>, <kvm@vger.kernel.org>, <agraf@suse.de>
Subject: Re: [PATCH 1/7 v2] KVM: PPC: e500: Expose MMU registers via ONE_REG
Date: Tue, 26 Mar 2013 17:42:33 -0500	[thread overview]
Message-ID: <1364337753.469.16@snotra> (raw)
In-Reply-To: <1364335512-28426-2-git-send-email-mihai.caraman@freescale.com> (from mihai.caraman@freescale.com on Tue Mar 26 17:05:06 2013)

On 03/26/2013 05:05:06 PM, Mihai Caraman wrote:
> +int kvmppc_set_one_reg_e500_tlb(struct kvm_vcpu *vcpu, u64 id,
> +			       union kvmppc_one_reg *val)
> +{
> +	int r = 0;
> +	long int i;
> +
> +	switch (id) {
> +	case KVM_REG_PPC_MAS0:
> +		vcpu->arch.shared->mas0 = set_reg_val(id, *val);
> +		break;
> +	case KVM_REG_PPC_MAS1:
> +		vcpu->arch.shared->mas1 = set_reg_val(id, *val);
> +		break;
> +	case KVM_REG_PPC_MAS2:
> +		vcpu->arch.shared->mas2 = set_reg_val(id, *val);
> +		break;
> +	case KVM_REG_PPC_MAS7_3:
> +		vcpu->arch.shared->mas7_3 = set_reg_val(id, *val);
> +		break;
> +	case KVM_REG_PPC_MAS4:
> +		vcpu->arch.shared->mas4 = set_reg_val(id, *val);
> +		break;
> +	case KVM_REG_PPC_MAS6:
> +		vcpu->arch.shared->mas6 = set_reg_val(id, *val);
> +		break;
> +	/* Only allow MMU registers to be set to the config supported  
> by KVM */
> +	case KVM_REG_PPC_MMUCFG: {
> +		if (set_reg_val(id, *val) != vcpu->arch.mmucfg)
> +			r = -EINVAL;
> +		break;
> +	}
> +	case KVM_REG_PPC_TLB0CFG:
> +	case KVM_REG_PPC_TLB1CFG:
> +	case KVM_REG_PPC_TLB2CFG:
> +	case KVM_REG_PPC_TLB3CFG: {
> +		/* MMU geometry (N_ENTRY/ASSOC) can be set only using  
> SW_TLB */
> +		i = id - KVM_REG_PPC_TLB0CFG;
> +		if (set_reg_val(id, *val) != vcpu->arch.tlbcfg[i])
> +			r = -EINVAL;
> +		break;
> +	}

Am I the only one that finds the set_reg_val/get_reg_val naming  
confusing?  At first glance it looks like it sets TLBnCFG and then  
later tests whether it should have. :-P

Functions should be named for what they do, not for what context you  
use them in.

-Scott

  reply	other threads:[~2013-03-26 22:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-26 22:05 [PATCH 0/7 v2] KVM: PPC: e500: Enable FSL e6500 core Mihai Caraman
2013-03-26 22:05 ` [PATCH 1/7 v2] KVM: PPC: e500: Expose MMU registers via ONE_REG Mihai Caraman
2013-03-26 22:42   ` Scott Wood [this message]
2013-04-04 13:26     ` Caraman Mihai Claudiu-B02008
2013-03-27 15:58   ` Alexander Graf
2013-03-26 22:05 ` [PATCH 2/7 v2] KVM: PPC: e500: Move vcpu's MMU configuration to dedicated functions Mihai Caraman
2013-03-26 22:05 ` [PATCH 3/7 v2] KVM: PPC: e500: Add support for TLBnPS registers Mihai Caraman
2013-03-26 22:48   ` Scott Wood
2013-03-26 22:05 ` [PATCH 4/7 v2] KVM: PPC: e500: Add support for EPTCFG register Mihai Caraman
2013-03-27 17:21   ` Alexander Graf
2013-03-26 22:05 ` [PATCH 5/7 v2] KVM: PPC: e500: Remove E.PT and E.HV.LRAT categories from VCPUs Mihai Caraman
2013-03-27 17:23   ` Alexander Graf
2013-03-27 17:50   ` Scott Wood
2013-03-26 22:05 ` [PATCH 6/7 v2] KVM: PPC: e500mc: Enable e6500 cores Mihai Caraman
2013-03-26 22:05 ` [PATCH 7/7 v2] KVM: PPC: e500: Add e6500 core to Kconfig description Mihai Caraman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364337753.469.16@snotra \
    --to=scottwood@freescale.com \
    --cc=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=mihai.caraman@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox