From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752244AbdAYUrW (ORCPT ); Wed, 25 Jan 2017 15:47:22 -0500 Received: from terminus.zytor.com ([65.50.211.136]:41980 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750915AbdAYUrU (ORCPT ); Wed, 25 Jan 2017 15:47:20 -0500 X-Greylist: delayed 550 seconds by postgrey-1.27 at vger.kernel.org; Wed, 25 Jan 2017 15:47:19 EST Subject: Re: [v3 PATCH 07/10] x86: Add emulation code for UMIP instructions To: Ricardo Neri , Ingo Molnar , Thomas Gleixner , Andy Lutomirski , Borislav Petkov References: <20170125202353.101059-1-ricardo.neri-calderon@linux.intel.com> <20170125202353.101059-8-ricardo.neri-calderon@linux.intel.com> Cc: Peter Zijlstra , Andrew Morton , Brian Gerst , Chris Metcalf , Dave Hansen , Paolo Bonzini , Liang Z Li , Masami Hiramatsu , Huang Rui , Jiri Slaby , Jonathan Corbet , "Michael S. Tsirkin" , Paul Gortmaker , Vlastimil Babka , Chen Yucong , Alexandre Julliard , Fenghua Yu , Stas Sergeev , "Ravi V. Shankar" , Shuah Khan , linux-kernel@vger.kernel.org, x86@kernel.org, linux-msdos@vger.kernel.org, wine-devel@winehq.org, Tony Luck From: "H. Peter Anvin" Message-ID: <145900b0-b386-e32c-cd79-cf7c47c14616@zytor.com> Date: Wed, 25 Jan 2017 12:38:55 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170125202353.101059-8-ricardo.neri-calderon@linux.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/25/17 12:23, Ricardo Neri wrote: > + case UMIP_SMSW: > + dummy_value = CR0_STATE; Unless the user space process is running in 64-bit mode this value should be & 0xffff. I'm not sure if we should even support fixing up UMIP instructions in 64-bit mode. Also, please put an explicit /* fall through */ here. > + /* > + * These two instructions return a 16-bit value. We return > + * all zeros. This is equivalent to a null descriptor for > + * str and sldt. > + */ > + case UMIP_SLDT: > + case UMIP_STR: > + /* if operand is a register, it is zero-extended*/ > + if (X86_MODRM_MOD(insn->modrm.value) == 3) { > + memset(data, 0, insn->opnd_bytes); > + *data_size = insn->opnd_bytes; > + /* if not, only the two least significant bytes are copied */ > + } else { > + *data_size = 2; > + } > + memcpy(data, &dummy_value, sizeof(dummy_value)); > + break; > + default: > + return -EINVAL; > + } > + return 0; > +bool fixup_umip_exception(struct pt_regs *regs) > +{ > + struct insn insn; > + unsigned char buf[MAX_INSN_SIZE]; > + /* 10 bytes is the maximum size of the result of UMIP instructions */ > + unsigned char dummy_data[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; > +#ifdef CONFIG_X86_64 > + int x86_64 = user_64bit_mode(regs); > +#else > + int x86_64 = 0; > +#endif Again, could we simply do: if (user_64bit_mode(regs)) return false; or are there known users of these instructions *in 64-bit mode*? -hpa