Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751524AbdGZUHd (ORCPT ); Wed, 26 Jul 2017 16:07:33 -0400 Received: from mail-by2nam03on0066.outbound.protection.outlook.com ([104.47.42.66]:4928 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751367AbdGZUH2 (ORCPT ); Wed, 26 Jul 2017 16:07:28 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Cc: brijesh.singh@amd.com, "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "linux-efi@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "kvm@vger.kernel.org" , Fenghua Yu , Matt Fleming , David Howells , Paul Mackerras , Christoph Lameter , Jonathan Corbet , =?UTF-8?Q?Radim_Krcm=c3=a1r?= , Piotr Luc , Ingo Molnar , Dave Airlie , Borislav Petkov , Tom Lendacky , Kees Cook , Konrad Rzeszutek Wilk , Reza Arbab , Andy Lutomirski , Thomas Gleixner , Laura Abbott , Tony Luck , Ard.Biesheuvel@zytor.com Subject: Re: [RFC Part1 PATCH v3 13/17] x86/io: Unroll string I/O when SEV is active To: "H. Peter Anvin" , Arnd Bergmann , David Laight References: <20170724190757.11278-1-brijesh.singh@amd.com> <20170724190757.11278-14-brijesh.singh@amd.com> <063D6719AE5E284EB5DD2968C1650D6DD003FB85@AcuExch.aculab.com> <201707261927.v6QJR228008075@mail.zytor.com> From: Brijesh Singh Message-ID: <589d65a4-eb09-bae9-e8b4-a2d78ca6b509@amd.com> Date: Wed, 26 Jul 2017 15:07:14 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <201707261927.v6QJR228008075@mail.zytor.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR1301CA0006.namprd13.prod.outlook.com (10.174.164.147) To BY2PR12MB0148.namprd12.prod.outlook.com (10.162.82.21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0260fc95-3778-4429-3855-08d4d461ed7b X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BY2PR12MB0148; X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0148;3:DYwSdQPsnm2PZVK1b8uhRIY2q0dAJXJu/Xh0gVWpO4S1jcdvDX2LqL5943uWb/kSpSdzN05sTiBZ7sRlLmffSZDvWFQeKJQxQSJtU/7S6Bym3M/gobSwopRWoG2Z8BQ7ZLgCQFARlNiRclxq+vH7hVep3oNqLbTGeJK8ymu0rhGXxs0G2yKH7JeYb4w0NiZziQmT5mzeM41HrizDiOmRY5aHKXV8Luhgpjiuerkm2Dm/KEOsfOdKE0uUmxSNU/HG4dNj46zX0bNkOM7YcFjyTMoEQ5slqLT3yMn4edbq1K6l4EgJlC4i82CVYO2wATyLBuuxcvOYWQCl1RssoutEE7DnxmMAJZGNvSbegD3AgLmiCaSxaiH1XxhuPMioLYs9RoRF9r2RLtCKP7txru1p56OzWxnqAEXWHEMZn2KLwLdR1BlVlPYxPgDkqr68FqrWbrc5dyxL87we1yhAllMkgt+W9Wi+1VqY6afHGDSyP1xiMwUdM9hy9McDtri/1tz11/gFQMbpueB42C+yzqo/M5zD//jaK/pjT452+4vGIG58ewyPJ9h/oHkZueeFow67e6CpTBzEzoc6FP++b41vrvzkXjVPTtsdCQO1yILV89OiOBBPa1t7DwMSIo2Jz9XZ095IBXDLnV8HYZm3v/+VheNJM1vNPJQYMPfpGqinkUzhmZA/Iyu/agKrkoFuMidGxX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s952+IiwP6ZoLxZ/6HRrJN6egAcFAO2PBvT8zc4eFMSCypGZntXg+LKaIYLM+v2ackYIP4ilkQ2EcpuGGTp41w+84bsCF/DxGPa1cnrwyWeo6PHxMt/c5NFjIwB7IpbOKaDTkOcCZGr9Q32aRgzZMyqnS+uxaRcv/fgdN+r2LgGLboCdQLjLKxw6gOB/BVD72QSe6lfHtYLmNH1qXcLWWg+8uaPBh7b X-Exchange-Antispam-Report-Test: UriScan:(17755550239193); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123562025)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY2PR12MB0148;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY2PR12MB0148; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjEyTUIwMTQ4OzQ6dlR2aHZBWjZ6TFM3ODgwSTRjNmtKeEhGL1No?= =?utf-8?B?L3R5UGppMXBFV3V2cTZKajdQYnJRdzY4ckpFcEdUbm4zNWEvTVkzaTZWUjh4?= =?utf-8?B?SER3KzNUd3hORFUrNVN3OUNUUUEvazJVSExkUzMweDMvaVJaZkpYYkppY1R2?= =?utf-8?B?UDFiR3Q2ODhQa09IbkxiSTVLaUlKd1lQZFVmY1V5dHJJN21BNHlEcGtuaDYy?= =?utf-8?B?d2ZXWW80Qi9nMHhNVG4rQURpbnNjdHo1Q3lrUEcraGh3ZmlicUs4c0xBbjZm?= =?utf-8?B?RzBpZFZMekFsYjJMVUdZZkZVdkluZ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N3U0MStwUzU4OFBUWXNGVTVDSVlSQTdGQXdTVDNkWUZt?= =?utf-8?B?U0hOaFZKNkdJa1dnWis5Z1hscFNXQVpjdHI1am9HZll4bkgvS1pYZFBidHFk?= =?utf-8?B?dnc5czZVT3dVeGpLTHl1bllveHZJVmhVWUtyTHU4cG51TlNkWTVSMVJkWmVB?= =?utf-8?B?ZFphMkpZdFZmalE1WDBrcDJScXlMM0FvTU5yS0hWK1Z4ZnQ5S3B5UW14WlZJ?= =?utf-8?B?bnoyZ3JZZHVXTTVXU0NjSEhvdysycGFJb3FkM3pjelJXblpOVzBITkE1VmNE?= =?utf-8?B?V3lnTUd4eW81RlJhY2d4QzFSZTBvK25JS1lVZS93Kzl5ZnBFU1V1STEzcDN4?= =?utf-8?B?MmZPK3J5eUNjSnY5ckd0SmxiOE84TW9wM09GQ3RpLytlMkpBWHMvaDZtdUNM?= =?utf-8?Q?oFsuiOlHUbIA63CoRoj?= X-Forefront-PRVS: 038002787A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(6049001)(39850400002)(39450400003)(39840400002)(39400400002)(39410400002)(24454002)(189002)(199003)(377454003)(66066001)(65956001)(81156014)(189998001)(47776003)(7350300001)(81166006)(38730400002)(64126003)(6246003)(23676002)(8676002)(6116002)(68736007)(93886004)(3846002)(83506001)(53936002)(65806001)(7416002)(5660300001)(65826007)(230700001)(97736004)(229853002)(25786009)(6666003)(478600001)(90366009)(77096006)(6486002)(86362001)(101416001)(2906002)(36756003)(4001350100001)(4326008)(54906002)(2950100002)(31696002)(42186005)(33646002)(31686004)(305945005)(7736002)(50466002)(76176999)(54356999)(966005)(105586002)(6306002)(106356001)(50986999)(53546010);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR12MB0148;H:[10.236.136.62];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjEyTUIwMTQ4OzIzOm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Vp1?= =?utf-8?Q?BGMBnQb?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0148;5:Zroo22y42agcx0O2tEb8rsWkhBi1TtqomK4vOAfAs4NpEx+EE+jRvUuBxuOhJDpOs/HhDitfRX33dhEJf+AjahRPRPOcO4Q34zAX982jDUpbi6DgITc469BVqvLCZXuyzzl85/eCTE4xCHCfD/16gGPFGgcAXYzQjZLstbY0Baqa2utrWuzPo1WVnzlP2/Ik4oc77X6qo9Ddyakfr1IsBuv9SJuscNY6pCCqUn8rsanBtegKalLxKfvtpahIXWKH/taqiVdiKH6eiU766HFtF+QFtc/2E/vnrPQlXqMlKH7hAZpovrbdIy2WbqYq1PpfrZkQsYfD9cbFQQ+96uTNxlPr9iQWQlvcGoR14uNgo1MoydGts9VwEtX0B2Oize6O/zJizoj2kZl4ahkwR4f+Pog+DTBD/sz3fsjQIeWIOymfSt9p3H5wjiXwMXvxLkaEopqu7T1Db6NzrfNMGuRAZjzg8H7sEs0TwPeRQUxwHXJRSNCEsao/XQCwI+7GyI2s;24:MnXQontbt+gEIR9l7X9hk4zMK6hhmC/a7Ex9buQ6xvfogA5S20PdC5+1kgAQ/jgCGBQbJyOR6jD7BCpZuG+91TtHKrQ++pUkaukIgIfl4+0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0148;7:Y9Ht4PwgpVAidlDhlMksCtNKw3ihXFQXg2TEZT+Bo+ZDoTsN/leswEffZ52APIVt3m4iWVXI4lRDqvAU8BKUeVO/ItVC/A/0dgvIIsd4VB7yzSyEPF2Zw2dWPZ+p4OjjHpS3Oz85y88D5ATP4k/ZvLJfTJzZPlt0iX4sy6OY07tXSRE2Zv5/nGuM7PmG/A9VWpY1dDJIYtSAATWiH8L/If5+1pBARjWGlTmkm7/BAsq0nN4lkni+Z413VPGbTEf7P/ao9n4T6eu5qPxOo51hHtht1AecZg0zLaNOjhPe2v+JK9AT24d/utV8kKCzvATmzXkAeFYzDLAp9HRzyzhTXtDZ7SYRfZv8qht83I9uOQte19ak7rnl+95eUfhGt1nsQnHreWjIshdgTczDkJiFVTKiB3GsBVQi55LlEVRtl0BGp75zLz5OsiBwJBcbZqPCtsBkqIobUIeqiHfSzIbTFSc+9fi1c+rv9H5J6on1gKJCmEGZD3XjXw7+V+xbV/3VvClsN3ZyvwJYVRXur+6sQn3MwUTkrZPfH5cU7zwy/45Q61bREu2T9uau6govelz+eTS/RN3ia07TQ/ri9fqQypsMooBYcEhD5L6kLu/GuFSSeXqaYE1vZyq4eJiRG05LfPtNTXUpJ+AWmkNAL/ufKS+VWHR4emk7xwz0k2IWEWu3rBBe44KFvSvqe/DRio00lVL09NudIZJsBybeUbyUvQrcT9RMaNpK5CVTmBUbiTEnmGkFr+GOoEzwYYUEb0vcFVdntll7sQs8hGZozBwJEha3Rd+jUVUHfEwQyDlov6w= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0148;20:5fkhVHp81zo5RN7+TCFwNT6ekSg68ZaSfzPjaUABVvZjH5cIKMm1cVsRMp20yvXI6d3TsqQHdbZJYPkVBKkgNjCIn/Mq3QRz6Zaaj8yNw5ZCxMMQ/p3+7Auz36vcA3pxowDEt3RfhldG5GabQtoHIIljE7bpqMi2TDdsZcKX0tgrF0Q7bBxbevXcZG74Wau8zQReFVLTWN9qqSFFVDkC9ja/Cdcy+0wLpuJ31IpApWdDvz9W9vGOi7+n3sEDGQlb X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2017 20:07:20.0292 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0148 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 8047 Lines: 238 On 07/26/2017 02:26 PM, H. Peter Anvin wrote: >>>>> >> \ >>>>> static inline void outs##bwl(int port, const void *addr, unsigned >> long count) \ >>>>> { >>> >>> This will clash with a fix I did to add a "memory" clobber >>> for the traditional implementation, see >>> https://patchwork.kernel.org/patch/9854573/ >>> >>>> Is it even worth leaving these as inline functions? >>>> Given the speed of IO cycles it is unlikely that the cost of calling >> a real >>>> function will be significant. >>>> The code bloat reduction will be significant. >>> >>> I think the smallest code would be the original "rep insb" etc, which >>> should be smaller than a function call, unlike the loop. Then again, >>> there is a rather small number of affected device drivers, almost all >>> of them for ancient hardware that you won't even build in a 64-bit >>> x86 kernel, see the list below. The only user I found that is >> actually >>> still relevant is drivers/tty/hvc/hvc_xen.c, which uses it for the >> early >>> console. >> >> >> There are some indirect user of string I/O functions. The following >> functions >> defined in lib/iomap.c calls rep version of ins and outs. >> >> - ioread8_rep, ioread16_rep, ioread32_rep >> - iowrite8_rep, iowrite16_rep, iowrite32_rep >> >> I found that several drivers use above functions. >> >> Here is one approach to convert it into non-inline functions. In this >> approach, >> I have added a new file arch/x86/kernel/io.c which provides non rep >> version of >> string I/O routines. The file gets built and used only when >> AMD_MEM_ENCRYPT is >> enabled. On positive side, if we don't build kernel with >> AMD_MEM_ENCRYPT support >> then we use inline routines, when AMD_MEM_ENCRYPT is built then we make >> a function >> call. Inside the function we unroll only when SEV is active. >> >> Do you see any issue with this approach ? thanks >> >> diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h >> index e080a39..104927d 100644 >> --- a/arch/x86/include/asm/io.h >> +++ b/arch/x86/include/asm/io.h >> @@ -323,8 +323,9 @@ static inline unsigned type in##bwl##_p(int port) >> \ >> unsigned type value = in##bwl(port); \ >> slow_down_io(); \ >> return value; \ >> -} >> \ >> - >> \ >> +} >> + >> +#define BUILDIO_REP(bwl, bw, type) >> \ >> static inline void outs##bwl(int port, const void *addr, unsigned long >> count) \ >> { >> \ >> asm volatile("rep; outs" #bwl \ >> @@ -335,12 +336,31 @@ static inline void ins##bwl(int port, void *addr, >> unsigned long count) \ >> { >> \ >> asm volatile("rep; ins" #bwl \ >> : "+D"(addr), "+c"(count) : "d"(port)); \ >> -} >> +} >> \ >> >> BUILDIO(b, b, char) >> BUILDIO(w, w, short) >> BUILDIO(l, , int) >> >> +#ifdef CONFIG_AMD_MEM_ENCRYPT >> +extern void outsb_try_rep(int port, const void *addr, unsigned long >> count); >> +extern void insb_try_rep(int port, void *addr, unsigned long count); >> +extern void outsw_try_rep(int port, const void *addr, unsigned long >> count); >> +extern void insw_try_rep(int port, void *addr, unsigned long count); >> +extern void outsl_try_rep(int port, const void *addr, unsigned long >> count); >> +extern void insl_try_rep(int port, void *addr, unsigned long count); >> +#define outsb outsb_try_rep >> +#define insb insb_try_rep >> +#define outsw outsw_try_rep >> +#define insw insw_try_rep >> +#define outsl outsl_try_rep >> +#define insl insl_try_rep >> +#else >> +BUILDIO_REP(b, b, char) >> +BUILDIO_REP(w, w, short) >> +BUILDIO_REP(l, , int) >> +#endif >> + >> extern void *xlate_dev_mem_ptr(phys_addr_t phys); >> extern void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr); >> >> diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile >> index a01892b..3b6e2a3 100644 >> --- a/arch/x86/kernel/Makefile >> +++ b/arch/x86/kernel/Makefile >> @@ -42,6 +42,7 @@ CFLAGS_irq.o := -I$(src)/../include/asm/trace >> >> obj-y := process_$(BITS).o signal.o >> obj-$(CONFIG_COMPAT) += signal_compat.o >> +obj-$(CONFIG_AMD_MEM_ENCRYPT) += io.o >> obj-y += traps.o irq.o irq_$(BITS).o >> dumpstack_$(BITS).o >> obj-y += time.o ioport.o dumpstack.o nmi.o >> obj-$(CONFIG_MODIFY_LDT_SYSCALL) += ldt.o >> diff --git a/arch/x86/kernel/io.c b/arch/x86/kernel/io.c >> new file mode 100644 >> index 0000000..f58afa9 >> --- /dev/null >> +++ b/arch/x86/kernel/io.c >> @@ -0,0 +1,87 @@ >> +#include >> +#include >> +#include >> + >> +void outsb_try_rep(int port, const void *addr, unsigned long count) >> +{ >> + if (sev_active()) { >> + unsigned char *value = (unsigned char *)addr; >> + while (count) { >> + outb(*value, port); >> + value++; >> + count--; >> + } >> + } else { >> + asm volatile("rep; outsb" : "+S"(addr), "+c"(count) : >> "d"(port)); >> + } >> +} >> + >> +void insb_try_rep(int port, void *addr, unsigned long count) >> +{ >> + if (sev_active()) { >> + unsigned char *value = (unsigned char *)addr; >> + while (count) { >> + *value = inb(port); >> + value++; >> + count--; >> + } >> + } else { >> + asm volatile("rep; insb" : "+D"(addr), "+c"(count) : >> "d"(port)); >> + } >> +} >> + >> +void outsw_try_rep(int port, const void *addr, unsigned long count) >> +{ >> + if (sev_active()) { >> + unsigned short *value = (unsigned short *)addr; >> + while (count) { >> + outw(*value, port); >> + value++; >> + count--; >> + } >> + } else { >> + asm volatile("rep; outsw" : "+S"(addr), "+c"(count) : >> "d"(port)); >> + } >> +} >> +void insw_try_rep(int port, void *addr, unsigned long count) >> +{ >> + if (sev_active()) { >> + unsigned short *value = (unsigned short *)addr; >> + while (count) { >> + *value = inw(port); >> + value++; >> + count--; >> + } >> + } else { >> + asm volatile("rep; insw" : "+D"(addr), "+c"(count) : >> "d"(port)); >> + } >> +} >> + >> +void outsl_try_rep(int port, const void *addr, unsigned long count) >> +{ >> + if (sev_active()) { >> + unsigned int *value = (unsigned int *)addr; >> + while (count) { >> + outl(*value, port); >> + value++; >> + count--; >> + } >> + } else { >> + asm volatile("rep; outsl" : "+S"(addr), "+c"(count) : >> "d"(port)); >> + } >> +} >> + >> +void insl_try_rep(int port, void *addr, unsigned long count) >> +{ >> + if (sev_active()) { >> + unsigned int *value = (unsigned int *)addr; >> + while (count) { >> + *value = inl(port); >> + value++; >> + count--; >> + } >> + } else { >> + asm volatile("rep; insl" : "+D"(addr), "+c"(count) : >> "d"(port)); >> + } >> +} > > What the heck? > I am not sure if I understand your concern. Are you commenting on amount of code duplication ? If so, I can certainly improve and use the similar macro used into header file to generate the functions body. Are you commenting that we should not attempt to make those functions non-inline and you prefer them to stay inline ? thanks