From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753203AbdCBPf6 (ORCPT ); Thu, 2 Mar 2017 10:35:58 -0500 Received: from mail-by2nam03on0049.outbound.protection.outlook.com ([104.47.42.49]:28249 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752544AbdCBPfI (ORCPT ); Thu, 2 Mar 2017 10:35:08 -0500 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Subject: [RFC PATCH v2 11/32] x86: Unroll string I/O when SEV is active From: Brijesh Singh To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Thu, 2 Mar 2017 10:14:35 -0500 Message-ID: <148846767530.2349.3396612151893482609.stgit@brijesh-build-machine> In-Reply-To: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> References: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR10CA0020.namprd10.prod.outlook.com (10.172.48.30) To CY4PR12MB1608.namprd12.prod.outlook.com (10.172.72.17) X-MS-Office365-Filtering-Correlation-Id: ac31d88c-c126-4802-93ed-08d4617edb01 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:CY4PR12MB1608; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1608;3:o9V2TnQeMDoAfVYryVZFcTbEpz1CeZCG7vfLg8CgqkYzLxCq3I5YeA1T6ZcFLlHePBA1HBgEv9OLBu6I8Gfu2i9qtLM9YHbrg4wRt1nSwCwf7len41eB2jiqJOLHBp4oOPp53xm7xS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Q8xwMH/wMocL+Wcp48gtYnn8Hg4PG/Yw1Yon06J+4ZSUMslnqWOfJpsh+BE/OInZwXpm8zDxUvdjv9zcS7vaofkeNVX0bvWuD8tQ/nAaVaOk6gD0rUliuKAV6aNPK2TuXxLh9pdG+ugbE3xYpStxirLCfsck4VnDoKWlS86u4aOL7sNeE+lZU77tpudLpVNEc+pxmD8pvRRijFVLYCoyXWNgoJgdo+Paj7y5J6SpWYN6wkJtWju3lRePdFE50wEbYrr3/UBQHBFMqSMlkmyQBjOxll/WD0potZZE5lwon3PjzpIluTXLbueg3/HiSkNwiiMGvkYLyqY3keejBvxoHTpql3QZu/f/U X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123555025)(20161123560025)(20161123564025)(20161123558025)(6072148);SRVR:CY4PR12MB1608;BCL:0;PCL:0;RULEID:;SRVR:CY4PR12MB1608; X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1608;4:iZKxHDb8sGQSzXaj6u4PoPYaAD6K+cW2BlcLWYoSxpqu/LQ/7ETqBfooeIAT1MUGcVbHNSNLZ8IsNhTcVu1yHZ+oPJZM9WpQC5jUkxlpAlh00JE90gQPgUpT1lpIfI0wIIfw+pyoiEELynAiVSsMEzepwdAhjDagodboI7S2fVOhLwaavYg4VVOPtwJJscfXqjWUUsg3Vw02myIHEwOZsJG8ppa62fAeMiE9RXLLgz2zLd7y1YACi3bg10AVMTNYc6pNfUPELKu2pTA6vAXFchSMb2rpTUu3jCiU02FDWKIKOTJF5WV8s/8TrxjdEsFQPnLk8sNHDxhrZq7NSgGbpSsmA09Rd6h/UmfUvBOiN1rCDPfEywFvUHYGxsDBHqa4Wwt5KpjQrXqxkYZuVL2clTOkSx464f6YPKdM9r0Bvnl9SWVQgd7zug2NZp+Nx3/ZBVWo38WU42b7baKlMIsFtiCGk2HakuIsaSwwx0VPnR3/j/TQspO0UsoeFixx6OSTCB2Xm1JQWztoS3pV+SD6Rw0ZuonDCE+iKJ/9whp0AKO+QIn1oV7UowX8Hqn7jqmIGqyCnWQD6aODzsBf+yTF1ByTWavTPt1FkPkI6uWqqGlH6iFm1itYCFmYwWgXf6uUwKVNhtVb3YTJ30g0NNJ2Yf8BuB5BMXMDMllNaHCLjdk= X-Forefront-PRVS: 023495660C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(39410400002)(39450400003)(39860400002)(39840400002)(39850400002)(7406005)(5660300001)(9686003)(83506001)(8676002)(92566002)(33646002)(7366002)(2906002)(42186005)(33716001)(103116003)(66066001)(7416002)(50466002)(81166006)(23676002)(1191002)(7736002)(47776003)(189998001)(53936002)(2201001)(38730400002)(25786008)(305945005)(50986999)(6116002)(3846002)(54356999)(86362001)(230700001)(76176999)(77096006)(6486002)(6666003)(2950100002)(90366009)(921003)(1121003)(84006005)(217873001)(2101003)(83996005);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR12MB1608;H:[127.0.1.1];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjEyTUIxNjA4OzIzOndsbkNOb0pNUEZDamlvc3gzK0pGa2pBZFNC?= =?utf-8?B?TTRQVUYydFRDY3BwTzU5TnZEL1V1d2VzaXN4MmpncnNMdG92OGowMUd3UzFT?= =?utf-8?B?K2NnRC9KNUtCY0g0dkp4YWg4R3pyMk5nb25IMWZIcDR5N2ZYTmgvNS9rVjZl?= =?utf-8?B?ZjdONGt3OTUrQmhvc3A3dS9tSTdBRFM3N091UGxlOVh6NVlBSG1NTzlQRmVR?= =?utf-8?B?YTBLa2c2RGk5eXhaU3ByVmNLbjM3VDA0aitJUVhQTXAzbUpvd0pUWTBnVXJP?= =?utf-8?B?Q3o0ZE9DVllNM2xDTlJkSGxi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HMSDc45sGA4aiola1M=;5:wvHDsLCd3hIOVj2EEV3A1hy80LHGjP0caicgbNcqv2p45rSiCrSiLSVAjhZ69+gC0+1Adyo23jBCsLynvu//VbJMWxJanBGoMSnNGfrtXXU9u4VBwJYDiYMVAaIuz1lxoRdyYs2pAvMeYP8SNgBW4g==;24:B81FftGIbzoBDvW2/12RwIvWiXq12ICkczjyeGCh4dlDEL1yCINR1IGC3lUOUONKv8bGDnXom6/lGY+fCJyPPcfszfK60eFX1WXay3S1pDA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR12MB1608;7:jdTr9YBW2IbMt1bHCs7NGZtza2/2f+MGJ15rejeYbmFMdegTXnU9OJcuY6d1jwqqQNJOwqf2yyYD/M0U47AZGn5BVhb9dbBPDjp4fhasU0BXrxSOW12Y3yguETEIl+xFNTRMgkhde7ZEegWoamwK4doG70Yj1kYg0N6BOLF9g8SW/CY8SWYjWSsH75fb5lD/dxZbR5C95Mii5L2XzVwRtD+t3goR9jSo7xb6Pw2P226a/CHf9nAF0XJFmeOpwX94r2vShfZOR8za6PchbzvqulvRC2mfg9LlhS/KEv2+AfHX1VxJ3RT10RFESS70fyxC8qBYGRFR60e9nr5PKl2KFA==;20:+SI5PP8VBcHxuGgih8cJFbm4I7I7rSnR1jypRtiAcF5QuAU/G1aMnStwREZzseZbKsYNa7zapA7pHNnbRGQM8LXIYx086QAeVOsEiNjcdiWN5awH8PYc/XqcbLEcvD0Tth2u8GzCkkjvF8RxwJUSD1xVHpINNfc5ENfXbIcwnnJT0BHeKyTc8UyKkRU6RcJwa2xYxlvK8QFC9dSX56gRze3NRcfFv3OT3QOckFY1qI+sfMtckN+jVwyGbNpKZhAY X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 15:14:39.0263 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1608 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Lendacky Secure Encrypted Virtualization (SEV) does not support string I/O, so unroll the string I/O operation into a loop operating on one element at a time. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/io.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 833f7cc..b596114 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -327,14 +327,32 @@ static inline unsigned type in##bwl##_p(int port) \ \ static inline void outs##bwl(int port, const void *addr, unsigned long count) \ { \ - asm volatile("rep; outs" #bwl \ - : "+S"(addr), "+c"(count) : "d"(port)); \ + if (sev_active()) { \ + unsigned type *value = (unsigned type *)addr; \ + while (count) { \ + out##bwl(*value, port); \ + value++; \ + count--; \ + } \ + } else { \ + asm volatile("rep; outs" #bwl \ + : "+S"(addr), "+c"(count) : "d"(port)); \ + } \ } \ \ static inline void ins##bwl(int port, void *addr, unsigned long count) \ { \ - asm volatile("rep; ins" #bwl \ - : "+D"(addr), "+c"(count) : "d"(port)); \ + if (sev_active()) { \ + unsigned type *value = (unsigned type *)addr; \ + while (count) { \ + *value = in##bwl(port); \ + value++; \ + count--; \ + } \ + } else { \ + asm volatile("rep; ins" #bwl \ + : "+D"(addr), "+c"(count) : "d"(port)); \ + } \ } BUILDIO(b, b, char) From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brijesh Singh Subject: [RFC PATCH v2 11/32] x86: Unroll string I/O when SEV is active Date: Thu, 2 Mar 2017 10:14:35 -0500 Message-ID: <148846767530.2349.3396612151893482609.stgit@brijesh-build-machine> References: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> Sender: owner-linux-mm@kvack.org To: simon.guinot@sequanux.org, linux-efi@vger.kernel.org, brijesh.singh@amd.com, kvm@vger.kernel.org, rkrcmar@redhat.com, matt@codeblueprint.co.uk, linux-pci@vger.kernel.org, linus.walleij@linaro.org, gary.hook@amd.com, linux-mm@kvack.org, paul.gortmaker@windriver.com, hpa@zytor.com, cl@linux.com, dan.j.williams@intel.com, aarcange@redhat.com, sfr@canb.auug.org.au, andriy.shevchenko@linux.intel.com, herbert@gondor.apana.org.au, bhe@redhat.com, xemul@parallels.com, joro@8bytes.org, x86@kernel.org, peterz@infradead.org, piotr.luc@intel.com, mingo@redhat.com, msalter@redhat.com, ross.zwisler@linux.intel.com, bp@suse.de, dyoung@redhat.com, thomas.lendacky@amd.com, jroedel@suse.de, keescook@chromium.org, arnd@arndb.de, toshi.kani@hpe.com, mathieu.desnoyers@efficios.com, luto@kernel.org, devel@linuxdriverproj List-Id: linux-efi@vger.kernel.org From: Tom Lendacky Secure Encrypted Virtualization (SEV) does not support string I/O, so unroll the string I/O operation into a loop operating on one element at a time. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/io.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 833f7cc..b596114 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -327,14 +327,32 @@ static inline unsigned type in##bwl##_p(int port) \ \ static inline void outs##bwl(int port, const void *addr, unsigned long count) \ { \ - asm volatile("rep; outs" #bwl \ - : "+S"(addr), "+c"(count) : "d"(port)); \ + if (sev_active()) { \ + unsigned type *value = (unsigned type *)addr; \ + while (count) { \ + out##bwl(*value, port); \ + value++; \ + count--; \ + } \ + } else { \ + asm volatile("rep; outs" #bwl \ + : "+S"(addr), "+c"(count) : "d"(port)); \ + } \ } \ \ static inline void ins##bwl(int port, void *addr, unsigned long count) \ { \ - asm volatile("rep; ins" #bwl \ - : "+D"(addr), "+c"(count) : "d"(port)); \ + if (sev_active()) { \ + unsigned type *value = (unsigned type *)addr; \ + while (count) { \ + *value = in##bwl(port); \ + value++; \ + count--; \ + } \ + } else { \ + asm volatile("rep; ins" #bwl \ + : "+D"(addr), "+c"(count) : "d"(port)); \ + } \ } BUILDIO(b, b, char) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brijesh Singh Subject: [RFC PATCH v2 11/32] x86: Unroll string I/O when SEV is active Date: Thu, 2 Mar 2017 10:14:35 -0500 Message-ID: <148846767530.2349.3396612151893482609.stgit@brijesh-build-machine> References: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , In-Reply-To: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> Sender: owner-linux-mm@kvack.org List-Id: kvm.vger.kernel.org From: Tom Lendacky Secure Encrypted Virtualization (SEV) does not support string I/O, so unroll the string I/O operation into a loop operating on one element at a time. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/io.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 833f7cc..b596114 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -327,14 +327,32 @@ static inline unsigned type in##bwl##_p(int port) \ \ static inline void outs##bwl(int port, const void *addr, unsigned long count) \ { \ - asm volatile("rep; outs" #bwl \ - : "+S"(addr), "+c"(count) : "d"(port)); \ + if (sev_active()) { \ + unsigned type *value = (unsigned type *)addr; \ + while (count) { \ + out##bwl(*value, port); \ + value++; \ + count--; \ + } \ + } else { \ + asm volatile("rep; outs" #bwl \ + : "+S"(addr), "+c"(count) : "d"(port)); \ + } \ } \ \ static inline void ins##bwl(int port, void *addr, unsigned long count) \ { \ - asm volatile("rep; ins" #bwl \ - : "+D"(addr), "+c"(count) : "d"(port)); \ + if (sev_active()) { \ + unsigned type *value = (unsigned type *)addr; \ + while (count) { \ + *value = in##bwl(port); \ + value++; \ + count--; \ + } \ + } else { \ + asm volatile("rep; ins" #bwl \ + : "+D"(addr), "+c"(count) : "d"(port)); \ + } \ } BUILDIO(b, b, char) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 1F9D86B039C for ; Thu, 2 Mar 2017 10:14:47 -0500 (EST) Received: by mail-pf0-f198.google.com with SMTP id x66so85042231pfb.2 for ; Thu, 02 Mar 2017 07:14:47 -0800 (PST) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0083.outbound.protection.outlook.com. [104.47.42.83]) by mx.google.com with ESMTPS id n1si7649891pgc.376.2017.03.02.07.14.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Mar 2017 07:14:46 -0800 (PST) Subject: [RFC PATCH v2 11/32] x86: Unroll string I/O when SEV is active From: Brijesh Singh Date: Thu, 2 Mar 2017 10:14:35 -0500 Message-ID: <148846767530.2349.3396612151893482609.stgit@brijesh-build-machine> In-Reply-To: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> References: <148846752022.2349.13667498174822419498.stgit@brijesh-build-machine> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: simon.guinot@sequanux.org, linux-efi@vger.kernel.org, brijesh.singh@amd.com, kvm@vger.kernel.org, rkrcmar@redhat.com, matt@codeblueprint.co.uk, linux-pci@vger.kernel.org, linus.walleij@linaro.org, gary.hook@amd.com, linux-mm@kvack.org, paul.gortmaker@windriver.com, hpa@zytor.com, cl@linux.com, dan.j.williams@intel.com, aarcange@redhat.com, sfr@canb.auug.org.au, andriy.shevchenko@linux.intel.com, herbert@gondor.apana.org.au, bhe@redhat.com, xemul@parallels.com, joro@8bytes.org, x86@kernel.org, peterz@infradead.org, piotr.luc@intel.com, mingo@redhat.com, msalter@redhat.com, ross.zwisler@linux.intel.com, bp@suse.de, dyoung@redhat.com, thomas.lendacky@amd.com, jroedel@suse.de, keescook@chromium.org, arnd@arndb.de, toshi.kani@hpe.com, mathieu.desnoyers@efficios.com, luto@kernel.org, devel@linuxdriverproject.org, bhelgaas@google.com, tglx@linutronix.de, mchehab@kernel.org, iamjoonsoo.kim@lge.com, labbott@fedoraproject.org, tony.luck@intel.com, alexandre.bounine@idt.com, kuleshovmail@gmail.com, linux-kernel@vger.kernel.org, mcgrof@kernel.org, mst@redhat.com, linux-crypto@vger.kernel.org, tj@kernel.org, pbonzini@redhat.com, akpm@linux-foundation.org, davem@davemloft.net From: Tom Lendacky Secure Encrypted Virtualization (SEV) does not support string I/O, so unroll the string I/O operation into a loop operating on one element at a time. Signed-off-by: Tom Lendacky --- arch/x86/include/asm/io.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 833f7cc..b596114 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -327,14 +327,32 @@ static inline unsigned type in##bwl##_p(int port) \ \ static inline void outs##bwl(int port, const void *addr, unsigned long count) \ { \ - asm volatile("rep; outs" #bwl \ - : "+S"(addr), "+c"(count) : "d"(port)); \ + if (sev_active()) { \ + unsigned type *value = (unsigned type *)addr; \ + while (count) { \ + out##bwl(*value, port); \ + value++; \ + count--; \ + } \ + } else { \ + asm volatile("rep; outs" #bwl \ + : "+S"(addr), "+c"(count) : "d"(port)); \ + } \ } \ \ static inline void ins##bwl(int port, void *addr, unsigned long count) \ { \ - asm volatile("rep; ins" #bwl \ - : "+D"(addr), "+c"(count) : "d"(port)); \ + if (sev_active()) { \ + unsigned type *value = (unsigned type *)addr; \ + while (count) { \ + *value = in##bwl(port); \ + value++; \ + count--; \ + } \ + } else { \ + asm volatile("rep; ins" #bwl \ + : "+D"(addr), "+c"(count) : "d"(port)); \ + } \ } BUILDIO(b, b, char) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org