From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Roedel, Joerg" Subject: Re: [PATCH 04/15] KVM: x86 emulator: Add check_perm callback Date: Mon, 4 Apr 2011 12:23:48 +0200 Message-ID: <20110404102348.GD23633@amd.com> References: <1301667024-29420-1-git-send-email-joerg.roedel@amd.com> <1301667024-29420-5-git-send-email-joerg.roedel@amd.com> <4D986990.1090604@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Cc: Marcelo Tosatti , "kvm@vger.kernel.org" To: Avi Kivity Return-path: Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:32660 "EHLO TX2EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753266Ab1DDKXz (ORCPT ); Mon, 4 Apr 2011 06:23:55 -0400 Content-Disposition: inline In-Reply-To: <4D986990.1090604@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Apr 03, 2011 at 08:35:28AM -0400, Avi Kivity wrote: > On 04/01/2011 05:10 PM, Joerg Roedel wrote: > > This patch adds a check_perm callback for each opcode into > > the instruction emulator. This will be used to do all > > necessary permission checks on instructions before checking > > whether they are intercepted or not. > > > > > > @@ -216,6 +216,7 @@ struct decode_cache { > > u8 seg_override; > > unsigned int d; > > int (*execute)(struct x86_emulate_ctxt *ctxt); > > + int (*check_perm)(struct x86_emulate_ctxt *ctxt); > > I originally mean to use a group-like structure to have check_perm only > when needed, but I guess this is a premature optimization. #define D(_y) > { .flags = (_y) } > > #define DI(_y, _i) { .flags = (_y), .intercept = x86_intercept_##_i } > > +#define DIP(_y, _i) { .flags = (_y), .intercept = x86_intercept_##_i, \ > > + .check_perm = em_check_perm_##_i } > > Sorry, this (and all the #defines which follow) are just obfuscating. I > set a bad example here, but the following patches show there is nothing > gained by the ## games. Please use the full function name. Yeah, this became a bit obfuscating in the end. My intention was to keep the opcode tables clean and readable, but I changed it now and added the check-functions directly removing all the #defines. Joerg -- AMD Operating System Research Center Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632