From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>, Ingo Molnar <mingo@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@suse.de>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Brian Gerst <brgerst@gmail.com>,
Chris Metcalf <cmetcalf@mellanox.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Huang Rui <ray.huang@amd.com>, Jiri Slaby <jslaby@suse.cz>,
Jonathan Corbet <corbet@lwn.net>,
"Michael S. Tsirkin" <mst@redhat.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Vlastimil Babka <vbabka@suse.cz>, Chen Yucong <slaoub@gmail.com>,
"Ravi V. Shankar" <ravi.v.shankar@intel.com>,
Shuah Khan <shuah@kernel.org>,
linux-kernel@vger.kernel.org, x86@kernel.org,
ricardo.neri@intel.com,
Adam Buchbinder <adam.buchbinder@gmail.com>,
Colin Ian King <colin.king@canonical.com>,
Lorenzo Stoakes <lstoakes@gmail.com>,
Qiaowei Ren <qiaowei.ren@intel.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Kees Cook <keescook@chromium.org>,
Thomas Garnier <thgarnie@google.com>,
Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH v10 02/13] x86/insn-eval: Compute linear address in several utility functions
Date: Thu, 2 Nov 2017 19:46:20 -0700 [thread overview]
Message-ID: <20171103024620.GB24896@voyager> (raw)
In-Reply-To: <alpine.DEB.2.20.1711021206200.2090@nanos>
On Thu, Nov 02, 2017 at 12:07:13PM +0100, Thomas Gleixner wrote:
> On Thu, 2 Nov 2017, Ingo Molnar wrote:
>
> > * Ricardo Neri <ricardo.neri-calderon@linux.intel.com> wrote:
> >
> > > + /*
> > > + * -EDOM means that we must ignore the address_offset. In such a case,
> > > + * in 64-bit mode the effective address relative to the RIP of the
> > > + * following instruction.
> > > + */
> > > + if (*regoff == -EDOM) {
> > > + if (user_64bit_mode(regs))
> > > + tmp = (long)regs->ip + insn->length;
> > > + else
> > > + tmp = 0;
> > > + } else if (*regoff < 0) {
> > > + return -EINVAL;
> > > + } else {
> > > + tmp = (long)regs_get_register(regs, *regoff);
> > > + }
> >
> > > + else
> > > + indx = (long)regs_get_register(regs, indx_offset);
> >
> > This and subsequent patches include a disgustly insane amount of type casts - why?
> >
> > For example here 'tmp' is 'long', while regs_get_register() returns
> > 'unsigned long', but no type cast is necessary for that.
> >
> > > + ret = get_eff_addr_modrm(insn, regs, &addr_offset,
> > > + &eff_addr);
> >
> > Also, please don't break lines slightly longer than 80 cols just to pacify
> > checkpatch (and this holds for other patches as well) - the cure is worse than the
> > illness!
>
> The right thing to do here is to split out stuff into a helper function
> which removes the indentation levels or restructure the code to avoid them.
This patch introduce this several helper function. Perhaps I can add some more. For
this particular case, I think that using shorter variable names will avoid this
problem.
Thanks and BR,
Ricardo
next prev parent reply other threads:[~2017-11-03 2:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-27 23:51 [PATCH v10 00/13] x86: Enable User-Mode Instruction Prevention Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 01/13] x86/insn-eval: Extend get_seg_base_addr() to also obtain segment limit Ricardo Neri
2017-11-02 9:37 ` [tip:x86/mpx] " tip-bot for Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 02/13] x86/insn-eval: Compute linear address in several utility functions Ricardo Neri
2017-11-02 8:51 ` Ingo Molnar
2017-11-02 11:07 ` Thomas Gleixner
2017-11-03 2:46 ` Ricardo Neri [this message]
2017-11-03 2:44 ` Ricardo Neri
2017-11-03 10:17 ` Ingo Molnar
2017-11-04 0:40 ` Ricardo Neri
2017-11-04 8:26 ` Ingo Molnar
2017-10-27 23:51 ` [PATCH v10 03/13] x86/insn-eval: Add support to resolve 32-bit address encodings Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 04/13] x86/insn-eval: Add wrapper function for 32 and 64-bit addresses Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 05/13] x86/insn-eval: Handle 32-bit address encodings in virtual-8086 mode Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 06/13] x86/insn-eval: Add support to resolve 16-bit address encodings Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 07/13] x86/cpufeature: Add User-Mode Instruction Prevention definitions Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 08/13] x86: Add emulation code for UMIP instructions Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 09/13] x86/umip: Force a page fault when unable to copy emulated result to user Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 10/13] x86: Enable User-Mode Instruction Prevention Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 11/13] x86/traps: Fixup general protection faults caused by UMIP Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 12/13] selftests/x86: Add tests for User-Mode Instruction Prevention Ricardo Neri
2017-10-27 23:51 ` [PATCH v10 13/13] selftests/x86: Add tests for instruction str and sldt Ricardo Neri
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=20171103024620.GB24896@voyager \
--to=ricardo.neri-calderon@linux.intel.com \
--cc=acme@redhat.com \
--cc=adam.buchbinder@gmail.com \
--cc=adrian.hunter@intel.com \
--cc=akpm@linux-foundation.org \
--cc=bp@suse.de \
--cc=brgerst@gmail.com \
--cc=cmetcalf@mellanox.com \
--cc=colin.king@canonical.com \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=dvyukov@google.com \
--cc=hpa@zytor.com \
--cc=jslaby@suse.cz \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lstoakes@gmail.com \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=mst@redhat.com \
--cc=paul.gortmaker@windriver.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=qiaowei.ren@intel.com \
--cc=ravi.v.shankar@intel.com \
--cc=ray.huang@amd.com \
--cc=ricardo.neri@intel.com \
--cc=shuah@kernel.org \
--cc=slaoub@gmail.com \
--cc=tglx@linutronix.de \
--cc=thgarnie@google.com \
--cc=vbabka@suse.cz \
--cc=x86@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).