From: Janosch Frank <frankja@linux.vnet.ibm.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: KVM <kvm@vger.kernel.org>, Cornelia Huck <cohuck@redhat.com>,
linux-s390 <linux-s390@vger.kernel.org>,
David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH v2 2/2] KVM: s390: use switch vs jump table in intercept.c
Date: Thu, 8 Feb 2018 09:30:11 +0100 [thread overview]
Message-ID: <534e2dae-16e7-31a9-5e1d-3fab4d659a66@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180206124700.19177-1-borntraeger@de.ibm.com>
[-- Attachment #1.1: Type: text/plain, Size: 3408 bytes --]
On 06.02.2018 13:47, Christian Borntraeger wrote:
> Instead of having huge jump tables for function selection,
> let's use normal switch/case statements for the instruction
> handlers in intercept.c We can now also get rid of
> intercept_handler_t.
>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: David Hildenbrand <david@redhat.com>
Looks good to me and results in less scrolling to find the handlers.
Reviewed-by: Janosch Frank <frankja@linux.vnet.ibm.com>
> ---
> arch/s390/kvm/intercept.c | 51 +++++++++++++++++++++++++++--------------------
> arch/s390/kvm/kvm-s390.h | 2 --
> 2 files changed, 29 insertions(+), 24 deletions(-)
>
> diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
> index 9c7d70715862..07c6e81163bf 100644
> --- a/arch/s390/kvm/intercept.c
> +++ b/arch/s390/kvm/intercept.c
> @@ -22,22 +22,6 @@
> #include "trace.h"
> #include "trace-s390.h"
>
> -
> -static const intercept_handler_t instruction_handlers[256] = {
> - [0x01] = kvm_s390_handle_01,
> - [0x82] = kvm_s390_handle_lpsw,
> - [0x83] = kvm_s390_handle_diag,
> - [0xaa] = kvm_s390_handle_aa,
> - [0xae] = kvm_s390_handle_sigp,
> - [0xb2] = kvm_s390_handle_b2,
> - [0xb6] = kvm_s390_handle_stctl,
> - [0xb7] = kvm_s390_handle_lctl,
> - [0xb9] = kvm_s390_handle_b9,
> - [0xe3] = kvm_s390_handle_e3,
> - [0xe5] = kvm_s390_handle_e5,
> - [0xeb] = kvm_s390_handle_eb,
> -};
> -
> u8 kvm_s390_get_ilen(struct kvm_vcpu *vcpu)
> {
> struct kvm_s390_sie_block *sie_block = vcpu->arch.sie_block;
> @@ -129,16 +113,39 @@ static int handle_validity(struct kvm_vcpu *vcpu)
>
> static int handle_instruction(struct kvm_vcpu *vcpu)
> {
> - intercept_handler_t handler;
> -
> vcpu->stat.exit_instruction++;
> trace_kvm_s390_intercept_instruction(vcpu,
> vcpu->arch.sie_block->ipa,
> vcpu->arch.sie_block->ipb);
> - handler = instruction_handlers[vcpu->arch.sie_block->ipa >> 8];
> - if (handler)
> - return handler(vcpu);
> - return -EOPNOTSUPP;
> +
> + switch (vcpu->arch.sie_block->ipa >> 8) {
> + case 0x01:
> + return kvm_s390_handle_01(vcpu);
> + case 0x82:
> + return kvm_s390_handle_lpsw(vcpu);
> + case 0x83:
> + return kvm_s390_handle_diag(vcpu);
> + case 0xaa:
> + return kvm_s390_handle_aa(vcpu);
> + case 0xae:
> + return kvm_s390_handle_sigp(vcpu);
> + case 0xb2:
> + return kvm_s390_handle_b2(vcpu);
> + case 0xb6:
> + return kvm_s390_handle_stctl(vcpu);
> + case 0xb7:
> + return kvm_s390_handle_lctl(vcpu);
> + case 0xb9:
> + return kvm_s390_handle_b9(vcpu);
> + case 0xe3:
> + return kvm_s390_handle_e3(vcpu);
> + case 0xe5:
> + return kvm_s390_handle_e5(vcpu);
> + case 0xeb:
> + return kvm_s390_handle_eb(vcpu);
> + default:
> + return -EOPNOTSUPP;
> + }
> }
>
> static int inject_prog_on_prog_intercept(struct kvm_vcpu *vcpu)
> diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
> index bd31b37b0e6f..3c0a975c2477 100644
> --- a/arch/s390/kvm/kvm-s390.h
> +++ b/arch/s390/kvm/kvm-s390.h
> @@ -19,8 +19,6 @@
> #include <asm/processor.h>
> #include <asm/sclp.h>
>
> -typedef int (*intercept_handler_t)(struct kvm_vcpu *vcpu);
> -
> /* Transactional Memory Execution related macros */
> #define IS_TE_ENABLED(vcpu) ((vcpu->arch.sie_block->ecb & ECB_TE))
> #define TDB_FORMAT1 1
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2018-02-08 8:30 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-06 11:21 [PATCH 0/2] KVM: s390: avoid jump tables Christian Borntraeger
2018-02-06 11:21 ` [PATCH 1/2] KVM: s390: use switch vs jump table in priv.c Christian Borntraeger
2018-02-06 12:02 ` Cornelia Huck
2018-02-06 12:32 ` David Hildenbrand
2018-02-08 8:01 ` Heiko Carstens
2018-02-08 9:16 ` Janosch Frank
2018-02-06 11:21 ` [PATCH 2/2] KVM: s390: use switch vs jump table in intercept.c Christian Borntraeger
2018-02-06 12:04 ` Cornelia Huck
2018-02-06 12:05 ` Christian Borntraeger
2018-02-06 12:34 ` David Hildenbrand
2018-02-06 12:47 ` [PATCH v2 " Christian Borntraeger
2018-02-06 12:51 ` Cornelia Huck
2018-02-08 8:30 ` Janosch Frank [this message]
2018-02-06 12:30 ` [PATCH 0/2] KVM: s390: avoid jump tables David Hildenbrand
2018-02-06 12:36 ` Christian Borntraeger
2018-02-06 12:42 ` David Hildenbrand
2018-02-08 8:58 ` Heiko Carstens
2018-02-08 9:07 ` Christian Borntraeger
2018-02-08 9:18 ` Christian Borntraeger
2018-02-08 10:09 ` Christian Borntraeger
2018-02-08 10:18 ` Cornelia Huck
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=534e2dae-16e7-31a9-5e1d-3fab4d659a66@linux.vnet.ibm.com \
--to=frankja@linux.vnet.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).