From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 32/34] cpcmd: fix inline assembly usage.
Date: Thu, 04 Oct 2007 13:27:38 +0200 [thread overview]
Message-ID: <20071004112833.790464002@de.ibm.com> (raw)
In-Reply-To: 20071004112706.574737175@de.ibm.com
[-- Attachment #1: 032-cpcmd-inline.diff --]
[-- Type: text/plain, Size: 4359 bytes --]
From: Heiko Carstens <heiko.carstens@de.ibm.com>
After assigning values to specific registers memset was called. This
may clobber the contents of the used registers.
To solve this extract the two used inline assemblies into small
functions that don't call any functions.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
arch/s390/kernel/cpcmd.c | 100 +++++++++++++++++++++++++----------------------
1 file changed, 55 insertions(+), 45 deletions(-)
Index: quilt-2.6/arch/s390/kernel/cpcmd.c
===================================================================
--- quilt-2.6.orig/arch/s390/kernel/cpcmd.c
+++ quilt-2.6/arch/s390/kernel/cpcmd.c
@@ -2,7 +2,7 @@
* arch/s390/kernel/cpcmd.c
*
* S390 version
- * Copyright (C) 1999,2005 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Copyright IBM Corp. 1999,2007
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
* Christian Borntraeger (cborntra@de.ibm.com),
*/
@@ -21,6 +21,49 @@
static DEFINE_SPINLOCK(cpcmd_lock);
static char cpcmd_buf[241];
+static int diag8_noresponse(int cmdlen)
+{
+ register unsigned long reg2 asm ("2") = (addr_t) cpcmd_buf;
+ register unsigned long reg3 asm ("3") = cmdlen;
+
+ asm volatile(
+#ifndef CONFIG_64BIT
+ " diag %1,%0,0x8\n"
+#else /* CONFIG_64BIT */
+ " sam31\n"
+ " diag %1,%0,0x8\n"
+ " sam64\n"
+#endif /* CONFIG_64BIT */
+ : "+d" (reg3) : "d" (reg2) : "cc");
+ return reg3;
+}
+
+static int diag8_response(int cmdlen, char *response, int *rlen)
+{
+ register unsigned long reg2 asm ("2") = (addr_t) cpcmd_buf;
+ register unsigned long reg3 asm ("3") = (addr_t) response;
+ register unsigned long reg4 asm ("4") = cmdlen | 0x40000000L;
+ register unsigned long reg5 asm ("5") = *rlen;
+
+ asm volatile(
+#ifndef CONFIG_64BIT
+ " diag %2,%0,0x8\n"
+ " brc 8,1f\n"
+ " ar %1,%4\n"
+#else /* CONFIG_64BIT */
+ " sam31\n"
+ " diag %2,%0,0x8\n"
+ " sam64\n"
+ " brc 8,1f\n"
+ " agr %1,%4\n"
+#endif /* CONFIG_64BIT */
+ "1:\n"
+ : "+d" (reg4), "+d" (reg5)
+ : "d" (reg2), "d" (reg3), "d" (*rlen) : "cc");
+ *rlen = reg5;
+ return reg4;
+}
+
/*
* __cpcmd has some restrictions over cpcmd
* - the response buffer must reside below 2GB (if any)
@@ -28,59 +71,27 @@ static char cpcmd_buf[241];
*/
int __cpcmd(const char *cmd, char *response, int rlen, int *response_code)
{
- unsigned cmdlen;
- int return_code, return_len;
+ int cmdlen;
+ int rc;
+ int response_len;
cmdlen = strlen(cmd);
BUG_ON(cmdlen > 240);
memcpy(cpcmd_buf, cmd, cmdlen);
ASCEBC(cpcmd_buf, cmdlen);
- if (response != NULL && rlen > 0) {
- register unsigned long reg2 asm ("2") = (addr_t) cpcmd_buf;
- register unsigned long reg3 asm ("3") = (addr_t) response;
- register unsigned long reg4 asm ("4") = cmdlen | 0x40000000L;
- register unsigned long reg5 asm ("5") = rlen;
-
+ if (response) {
memset(response, 0, rlen);
- asm volatile(
-#ifndef CONFIG_64BIT
- " diag %2,%0,0x8\n"
- " brc 8,1f\n"
- " ar %1,%4\n"
-#else /* CONFIG_64BIT */
- " sam31\n"
- " diag %2,%0,0x8\n"
- " sam64\n"
- " brc 8,1f\n"
- " agr %1,%4\n"
-#endif /* CONFIG_64BIT */
- "1:\n"
- : "+d" (reg4), "+d" (reg5)
- : "d" (reg2), "d" (reg3), "d" (rlen) : "cc");
- return_code = (int) reg4;
- return_len = (int) reg5;
- EBCASC(response, rlen);
+ response_len = rlen;
+ rc = diag8_response(cmdlen, response, &rlen);
+ EBCASC(response, response_len);
} else {
- register unsigned long reg2 asm ("2") = (addr_t) cpcmd_buf;
- register unsigned long reg3 asm ("3") = cmdlen;
- return_len = 0;
- asm volatile(
-#ifndef CONFIG_64BIT
- " diag %1,%0,0x8\n"
-#else /* CONFIG_64BIT */
- " sam31\n"
- " diag %1,%0,0x8\n"
- " sam64\n"
-#endif /* CONFIG_64BIT */
- : "+d" (reg3) : "d" (reg2) : "cc");
- return_code = (int) reg3;
+ rc = diag8_noresponse(cmdlen);
}
- if (response_code != NULL)
- *response_code = return_code;
- return return_len;
+ if (response_code)
+ *response_code = rc;
+ return rlen;
}
-
EXPORT_SYMBOL(__cpcmd);
int cpcmd(const char *cmd, char *response, int rlen, int *response_code)
@@ -109,5 +120,4 @@ int cpcmd(const char *cmd, char *respons
}
return len;
}
-
EXPORT_SYMBOL(cpcmd);
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
next prev parent reply other threads:[~2007-10-04 11:38 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-04 11:27 [patch 00/34] s390 patches for 2.6.24 Martin Schwidefsky
2007-10-04 11:27 ` [patch 01/34] cio: rename css to channel_subsystems Martin Schwidefsky
2007-10-04 11:27 ` [patch 02/34] cio: remove subchannel_add_files() Martin Schwidefsky
2007-10-04 11:27 ` [patch 03/34] cio: Fix some coding style issues in cmf Martin Schwidefsky
2007-10-04 11:27 ` [patch 04/34] cio: Kerneldoc comments for cmf Martin Schwidefsky
2007-10-04 11:27 ` [patch 05/34] cio: Add docbook comments Martin Schwidefsky
2007-10-04 11:27 ` [patch 06/34] cio: Add s390-drivers book Martin Schwidefsky
2007-10-04 11:27 ` [patch 07/34] cio: Minor style fixes Martin Schwidefsky
2007-10-04 11:27 ` [patch 08/34] cio: Disable channel path measurements on shutdown/reboot Martin Schwidefsky
2007-10-04 11:27 ` [patch 09/34] cio: Introduce ccw_bus_type.shutdown Martin Schwidefsky
2007-10-04 11:27 ` [patch 10/34] cio: Disable channel measurements (cmf) on shutdown/reboot Martin Schwidefsky
2007-10-04 11:27 ` [patch 11/34] cio: Fix device attributes for early devices Martin Schwidefsky
2007-10-04 11:27 ` [patch 12/34] Add Documentation/s390/00-INDEX Martin Schwidefsky
2007-10-04 11:27 ` [patch 13/34] cio: Documentation update Martin Schwidefsky
2007-10-04 11:27 ` [patch 14/34] zcrypt: make init/exit functions static Martin Schwidefsky
2007-10-04 11:27 ` [patch 15/34] zcrypt: remove duplicated struct CPRBX definition Martin Schwidefsky
2007-10-04 11:27 ` [patch 16/34] zcrypt: fix ap_reset_domain() Martin Schwidefsky
2007-10-04 11:27 ` [patch 17/34] appldata_base: Misc cpuinit annotations and bugfix Martin Schwidefsky
2007-10-04 11:27 ` [patch 18/34] appldata_base: Remove module_exit function and modular stuff Martin Schwidefsky
2007-10-04 11:27 ` [patch 19/34] disassembler: fix output for insns with 6 operands Martin Schwidefsky
2007-10-04 11:27 ` [patch 20/34] disassembler: Remove redundant variable assignment Martin Schwidefsky
2007-10-04 11:27 ` [patch 21/34] Get rid of a bunch of sparse warnings again Martin Schwidefsky
2007-10-04 11:27 ` [patch 22/34] remove packed attribute from ext_int_info_t Martin Schwidefsky
2007-10-04 11:27 ` [patch 23/34] Get rid of ARCH_KMALLOC_MINALIGN Martin Schwidefsky
2007-10-04 11:27 ` [patch 24/34] qdio: dont cast function pointers and use them to call functions Martin Schwidefsky
2007-10-04 11:27 ` [patch 25/34] is_power_of_2 in drivers/s390/block/dasd_int.h Martin Schwidefsky
2007-10-04 11:27 ` [patch 26/34] qdio: change QDIO performance_stats error message priority Martin Schwidefsky
2007-10-04 11:27 ` [patch 27/34] Force link error if xchg/cmpxchg gets called with unsupported size Martin Schwidefsky
2007-10-04 11:27 ` [patch 28/34] Use IPL CLEAR for reipl under z/VM Martin Schwidefsky
2007-10-04 11:27 ` [patch 29/34] Remove obsolete recommendation for 8M ramdisk size Martin Schwidefsky
2007-10-04 11:27 ` [patch 30/34] zcore: fix inline assembly in memcpy_real() Martin Schwidefsky
2007-10-04 11:27 ` [patch 31/34] Make vmalloc area start at address > 4GB Martin Schwidefsky
2007-10-04 11:27 ` Martin Schwidefsky [this message]
2007-10-04 11:27 ` [patch 33/34] tape: Fix medium state handling Martin Schwidefsky
2007-10-04 11:27 ` [patch 34/34] vmwatchdog: fix broken inline assembly Martin Schwidefsky
2007-10-04 19:10 ` [patch 00/34] s390 patches for 2.6.24 Sam Ravnborg
2007-10-05 8:30 ` Martin Schwidefsky
2007-10-04 19:15 ` [PATCH 1/2] s390: beautify vmlinux.lds Sam Ravnborg
2007-10-04 19:18 ` [PATCH 2/2] s390: use PAGE_SIZE in vmlinux.lds Sam Ravnborg
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=20071004112833.790464002@de.ibm.com \
--to=schwidefsky@de.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.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