From patchwork Thu Jan 23 08:22:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347029 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0600917EA for ; Thu, 23 Jan 2020 08:26:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA5B024125 for ; Thu, 23 Jan 2020 08:26:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA5B024125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXoz-0006Nc-Kg for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:26:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55916) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlI-00011S-2G for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlG-0002t7-HG for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:47 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:43277) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlG-0002oZ-7v for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:46 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MQdpG-1jI6E008HO-00NgMR; Thu, 23 Jan 2020 09:22:34 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 01/17] linux-user:Fix align mistake when mmap guest space Date: Thu, 23 Jan 2020 09:22:11 +0100 Message-Id: <20200123082227.2037994-2-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:qn6JMmYNdNfmHxOlpWiAP26Rna0EFvuX7k+7mR0zyHjLMOqIqmj x5rG3dVEp5JExxAcqTw9oOMaTchKpDUWX8gECl7qqtg2uH1Jp8NmxMyUG9XYf0/QqI8tBfc FdML4G1/VpDuqGhWqCUgdEIzFvgic0c1UhF2tSuo7fz6IPYmefvaxieUyWllBgXxeixIlT4 TyKtmyY7xhQV8nt2s9x1Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:Z6bhkNrDhUw=:ked2FmQBb06bKKCDfROfk5 uFUBR9SFI5GAzwpA+eNP4b59ahjuwkJ8o+7p88GDLTGLooJENDymIkfq2anMZQWFEh4RuuKHF kupz/WqgQYYZGzGSTa+ZyTZU9S4zM0vKvXgM0OaaSov7fRdp5TGy4ufxPW3MwsVwivmlzFJOW 8mTecrcN4ex23q/TN/QXnuiFwdvUbRq+LnKG2it1CoxpQgzhci06ceeyCbu9NhiPxY+5exDgW rEPgSfRR4H4o/XVfUbIxibQ1BaCM+wVRQlDWg/HkckmkcIA9Y96qb+kjtn/iHn8FKlhUE1yQS NPjylT9QNH9M2QQlW5yAfqb2zt9O0jGSvEW0wMgCQPujfVWxoXAjk5ioofF6HBqw2/Td8mf6P gzF7a6xCiOgv9sdDV07P69pJDypP1bDEVuVg8/4PNoAywPcXiOjczQA7ru0cLBOfZBt1PSE64 EjVA2udj8WdCU6E6irZC7NVnXKrNUqjNy/Y1AZoHNPcCb4m1t95SmQ0rgaIZ5K84IsGHOlW+Z YVuncRzC41kend++UoHxTtEd2VyefMjL6vhp0McI8gV2ZBfd6+RqPpBt1DwuulcT01I75mwwM 0cQp+SryIzV6GgegB6UI/6s4SJ6ZuEBrohOgxf7byd/0u4Pzv039kVTsC6IPiAKfKiK/NGRxd TAqzpXoNkOFmHVKH+bI2i1y25p2WjSMMr9yxHHzka8A32PqhT/e7BflsNeuyM55B58+weSMSW nibrXqnSgLd9z1BMrqltdUYaSw/YgWQF1eXekNrLR9coUrDO+SIrlO/5AE9MA4n0iLM0kq1g3 fIrO6FMDgXxu69j1huTxjXLmCleBk0ktoQza+IsCLX6q1z+6+U= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.131 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Richard Henderson , Laurent Vivier , Xinyu Li Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xinyu Li In init_guest_space, we need to mmap guest space. If the return address of first mmap is not aligned with align, which was set to MAX(SHMLBA, qemu_host_page_size), we need unmap and a new mmap(space is larger than first size). The new size is named real_size, which is aligned_size + qemu_host_page_size. alugned_size is the guest space size. And add a qemu_host_page_size to avoid memory error when we align real_start manually (ROUND_UP(real_start, align)). But when SHMLBA > qemu_host_page_size, the added size will smaller than the size to align, which can make a mistake(in a mips machine, it appears). So change real_size from aligned_size +qemu_host_page_size to aligned_size + align will solve it. Signed-off-by: Xinyu Li Reviewed-by: Richard Henderson Message-Id: <20191213022919.5934-1-precinct@mail.ustc.edu.cn> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 07b16cc0f470..511e4500788b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2191,7 +2191,7 @@ unsigned long init_guest_space(unsigned long host_start, * to where we need to put the commpage. */ munmap((void *)real_start, host_size); - real_size = aligned_size + qemu_host_page_size; + real_size = aligned_size + align; real_start = (unsigned long) mmap((void *)real_start, real_size, PROT_NONE, flags, -1, 0); if (real_start == (unsigned long)-1) { From patchwork Thu Jan 23 08:22:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347049 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5A036C1 for ; Thu, 23 Jan 2020 08:34:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A3F9E24655 for ; Thu, 23 Jan 2020 08:34:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3F9E24655 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXwR-00086e-Hw for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:34:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56001) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlM-00014r-0w for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlG-0002tW-ON for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:51 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:42647) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlG-0002qO-En for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:46 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mi2eP-1jXz7D2MDZ-00e7Vw; Thu, 23 Jan 2020 09:22:34 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 02/17] linux-user: Reserve space for brk Date: Thu, 23 Jan 2020 09:22:12 +0100 Message-Id: <20200123082227.2037994-3-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:yyYTQ6TTuAdWqXFFVCVNYHK+iP45nYTEaSADh1Q9vNrinQUKSRS mZ/H0r/XGc7aW7/FTxHC8nOo3dNwOScc4D5kycVu7od2tPtdAOv+usx0SOrP9G7NLvrktVZ QqyMv3TtHqVCnhbFAlIsc/3g7gf14C16cP0151xXxqR1JJjre8bHUVPW/YM4YlgvSLOvSIG fv7JleOOQzVg/LevBUmxA== X-UI-Out-Filterresults: notjunk:1;V03:K0:iRwKJMiXTTk=:7ZePQvzAleG+hYP2plFoBO e5T+pTe7gnjV/zEpITkFLIeV9u+3BQ2YDDDgggjIiR1jcNe0JZkskcGBp2Cfe08YvubG15/BH 5twqUjSbEYQ/F0NpzxyVNJfX57WqIobvsWPtkEOq8Cl54mVCQ1QedPNO9V6dSN2R+kmx4tuRC 2qOeIx8d6oAkrt+NQXeN2IY7PbsHo9bgqRbht4+P/r/aYd9goucl+gdRFwpKOK9sg/kSMIhY4 eB48P6eRSb7xRp0g+X3xW25T+Ztirix4cSkWHTnf/o9cPu9BKz0tAikGZ8zO9iU9GBENCebsV jUS5NdDodKyKrvx8+gmACts1cBRgyQuHeiB6nTOOekBSoTKkQPnxvmZbKRFu9D+/HnCMBI4q9 dZQsIhiGcBlstK4DmwSBYMHNPwIVRWuviJNRyyuAEm2oheL8DzIpBKVLAFV9JlauCkS5pWOVR HtbNNZ9Ogww8a0i+eEbReDQlua4iYQzxEeiJlYb/wNSDjD2TsOjaCTJq4TbZNE8JBqfPIGqcP 6PawTKdN1hoKra2Sg9cw3YDz42WPOwBDrjb3fp1qWeeAnmk0TGVNehKj9u7uIXjSKCe+GuBxS blDvlVkc3+8fzLFI/iQEPfyciCQWC2QuiGmTAfF87fMtWCt8fLpL/CetqxOQIIbT5DMgzx3aq Trkh7Zaj5C4EoQmsHB8DYpwsbUBQQig4pUcXFJ6/jF/91YiNM+nJWbVIFlnOcwy+OIEfTPknk 9zcvpCnyym2JSs7Dx5iawTGTmeMJhKLfYUdkNeGWWM4AbjKT4tHFCP4br8k5IC8KGB+yILPU3 TER3vrUvHh1Eu/tOl6UnlAu2mblmM5OnPsckpUgdr+mdcR8h8k= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.133 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Riku Voipio , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson With bad luck, we can wind up with no space at all for brk, which will generally cause the guest malloc to fail. This bad luck is easier to come by with ET_DYN (PIE) binaries, where either the stack or the interpreter (ld.so) gets placed immediately after the main executable. But there's nothing preventing this same thing from happening with ET_EXEC (normal) binaries, during probe_guest_base(). In both cases, reserve some extra space via mmap and release it back to the system after loading the interpreter and allocating the stack. The choice of 16MB is somewhat arbitrary. It's enough for libc to get going, but without being so large that 32-bit guests or 32-bit hosts are in danger of running out of virtual address space. It is expected that libc will be able to fall back to mmap arenas after the limited brk space is exhausted. Launchpad: https://bugs.launchpad.net/qemu/+bug/1749393 Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée Tested-by: Alex Bennée Message-Id: <20200117230245.5040-1-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 73 +++++++++++++++++++++++++++++++++----------- linux-user/qemu.h | 1 + 2 files changed, 57 insertions(+), 17 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 511e4500788b..f3080a16358c 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -10,6 +10,7 @@ #include "qemu/path.h" #include "qemu/queue.h" #include "qemu/guest-random.h" +#include "qemu/units.h" #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -2364,24 +2365,51 @@ static void load_elf_image(const char *image_name, int image_fd, } } - load_addr = loaddr; - if (ehdr->e_type == ET_DYN) { - /* The image indicates that it can be loaded anywhere. Find a - location that can hold the memory space required. If the - image is pre-linked, LOADDR will be non-zero. Since we do - not supply MAP_FIXED here we'll use that address if and - only if it remains available. */ - load_addr = target_mmap(loaddr, hiaddr - loaddr, PROT_NONE, - MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, - -1, 0); - if (load_addr == -1) { - goto exit_perror; + if (pinterp_name != NULL) { + /* + * This is the main executable. + * + * Reserve extra space for brk. + * We hold on to this space while placing the interpreter + * and the stack, lest they be placed immediately after + * the data segment and block allocation from the brk. + * + * 16MB is chosen as "large enough" without being so large + * as to allow the result to not fit with a 32-bit guest on + * a 32-bit host. + */ + info->reserve_brk = 16 * MiB; + hiaddr += info->reserve_brk; + + if (ehdr->e_type == ET_EXEC) { + /* + * Make sure that the low address does not conflict with + * MMAP_MIN_ADDR or the QEMU application itself. + */ + probe_guest_base(image_name, loaddr, hiaddr); } - } else if (pinterp_name != NULL) { - /* This is the main executable. Make sure that the low - address does not conflict with MMAP_MIN_ADDR or the - QEMU application itself. */ - probe_guest_base(image_name, loaddr, hiaddr); + } + + /* + * Reserve address space for all of this. + * + * In the case of ET_EXEC, we supply MAP_FIXED so that we get + * exactly the address range that is required. + * + * Otherwise this is ET_DYN, and we are searching for a location + * that can hold the memory space required. If the image is + * pre-linked, LOADDR will be non-zero, and the kernel should + * honor that address if it happens to be free. + * + * In both cases, we will overwrite pages in this range with mappings + * from the executable. + */ + load_addr = target_mmap(loaddr, hiaddr - loaddr, PROT_NONE, + MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | + (ehdr->e_type == ET_EXEC ? MAP_FIXED : 0), + -1, 0); + if (load_addr == -1) { + goto exit_perror; } load_bias = load_addr - loaddr; @@ -2860,6 +2888,17 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) bprm->core_dump = &elf_core_dump; #endif + /* + * If we reserved extra space for brk, release it now. + * The implementation of do_brk in syscalls.c expects to be able + * to mmap pages in this space. + */ + if (info->reserve_brk) { + abi_ulong start_brk = HOST_PAGE_ALIGN(info->brk); + abi_ulong end_brk = HOST_PAGE_ALIGN(info->brk + info->reserve_brk); + target_munmap(start_brk, end_brk - start_brk); + } + return 0; } diff --git a/linux-user/qemu.h b/linux-user/qemu.h index f6f5fe5fbb55..560a68090e14 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -35,6 +35,7 @@ struct image_info { abi_ulong end_data; abi_ulong start_brk; abi_ulong brk; + abi_ulong reserve_brk; abi_ulong start_mmap; abi_ulong start_stack; abi_ulong stack_limit; From patchwork Thu Jan 23 08:22:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347031 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F9D71580 for ; Thu, 23 Jan 2020 08:26:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F34C24125 for ; Thu, 23 Jan 2020 08:26:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F34C24125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXpF-0006qu-T1 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:26:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56002) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlM-00014t-3i for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlK-00032G-KT for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:51 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:39505) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlK-00030m-Al for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:50 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N6bPS-1jgTgr0XQk-017zXj; Thu, 23 Jan 2020 09:22:35 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 03/17] linux-user: Add support for FS_IOC_VERSION ioctls Date: Thu, 23 Jan 2020 09:22:13 +0100 Message-Id: <20200123082227.2037994-4-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:5+e8ly+M64AP+Fd9RcIlIR0MmRTynLhSFtzn9DW9MCwhG6dhmn6 I17Lmp0tzxas//xawK8xcJ2OLzZe62iDbN863PfFuKIJbZcvKzb3QY5vGhxQDBWRabmfnfH O4aIRxAZwApOXikf56dc47MHGcYHxLeAaUEdLG7Av2c+WcDDb6sPfgyYCVR44Yi8mTpop9C Mr7DtaDCC4J9ykSrWWsZQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:zGKMKVesmio=:RfR4q6OYN579CSUuJI9+1W agBD2kYKoeZ9NAEtq9sfB/6OeSVPY3urhw9YYxpcuxNv9I0CJ5gYoxDej3/WolAh610gvUSjD ADXHZQNRDlyefen3Xv6XYOuZGhEy+VC/iI9C1BEtSaeWz2MJ3YOgWWc2gqj7ShqheYmuraGXX Mphu6eWzna6XZnUh5Qd4y/RhoPRVO+f+niB0YeN4/aPe0dk3v8RH9l2MVllR4H4Yii43HOxUT 7I32kcLHDh9b264bUUTGJRrt6at4knC/jrDDm6E+rRy2vYypTQbl9cEQeAZxen4g6P79lWj2D 5TAibfnpDv3nR/RZGqJs3MJuKQv936WYEJEZarYR2OfFmDJmqB+zzwoA/TLLj8cBJs1sNV7gS tYBfBlV8kSPhPViHl6O2w48pQz2dM1iCxeqeW6UXT0WdO7su8OHmbYHE3q8DMP+PE/FeA3EOq m77oy8BwwqeT0tZPORp6G64Q8ymo8bl3rzv1/IO3FqQXKnfcIBRc/9bKC26FvWzG1tYSYkh4b AjbcBam6Qt5t1kmus6lLbGDSCes/5EyhH5uZwsE36PZWLreRvGJJezwd85Zr3EXbtJkTzWZ6t PB9VUOHjA7Bpdeb41Jk/eVM/F2gwCjO94S7nZir0cc4ssEckCzlX/V5UmLf123Hs2DSRr/kPF rB3LUVC9R0g08nmLnQQfJMjedxiwi6VWYxHWdBzjp5uku+OG8nbNSohmZ3gJVIUHsG8y77Y6r 8Bht39nWsyK0rYogCRAhEjL4+qOw2Wk0yE9mqGag3AbP9AZuDH1j0NJD2QLevOeZjw5BQB3Dw yxIDVFsOatbXc2cSwLTBZ2JG2Y5QLKiud64OsVytiYp3wjH1Jk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.134 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Aleksandar Markovic Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic A very specific thing for these two ioctls is that their code implies that their third argument is of type 'long', but the kernel uses that argument as if it is of type 'int'. This anomaly is recognized also in commit 6080723 (linux-user: Implement FS_IOC_GETFLAGS and FS_IOC_SETFLAGS ioctls). Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-2-git-send-email-aleksandar.markovic@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index c6b9d6ad6653..c44f42eaf4e7 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -138,6 +138,8 @@ IOCTL(FS_IOC_GETFLAGS, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC_SETFLAGS, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) #ifdef CONFIG_USBFS /* USB ioctls */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 98c2119de9c1..f68a8b6e8e18 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -911,12 +911,14 @@ struct target_pollfd { #define TARGET_FICLONE TARGET_IOW(0x94, 9, int) #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range) -/* Note that the ioctl numbers claim type "long" but the actual type - * used by the kernel is "int". +/* + * Note that the ioctl numbers for FS_IOC_ + * claim type "long" but the actual type used by the kernel is "int". */ #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long) #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long) - +#define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long) +#define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long) #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap) /* usb ioctls */ From patchwork Thu Jan 23 08:22:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347021 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F8EC139A for ; Thu, 23 Jan 2020 08:24:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F385F24125 for ; Thu, 23 Jan 2020 08:24:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F385F24125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXmZ-0002oH-CM for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:24:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55915) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlI-00011R-29 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlE-0002nv-S5 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:47 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:55499) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlD-0002gf-5c for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:44 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MplLZ-1jO7l82WDd-00qBoC; Thu, 23 Jan 2020 09:22:35 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 04/17] linux-user: Add support for FS_IOC32_FLAGS ioctls Date: Thu, 23 Jan 2020 09:22:14 +0100 Message-Id: <20200123082227.2037994-5-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:eUWuUMDAVRWaHN3nTmOWiEuJiOsj+shrFkYHJqyp7VZeoVJ/yLz 6VAYO1KZHx8E3lvnRW03Bu91CtkhvIVNgxwo6RO7ckRmH1ViwYadRXALnxNPP3bmzXy5OLV qvLOTmirg+dnwtCqRP74r3OoieM0g+cFBwq5s+gYObDbBuapxFlO95gS1WqgcXrueZ7secU 0tLEXIgR4rrzx78Tws4yw== X-UI-Out-Filterresults: notjunk:1;V03:K0:+l9JbOgRqAk=:A8E4aF8hslYpT17kUBlTj3 mUCVUM8ZR38V7YaK3uhVjRwI1ZXpUcgFulcSou9E+2UMnXJVQqqUMoBIUaTaq6q1WrZVodIZK WmR7MBsHKRD5W2q7b/opfFqqa5/sf5GhOjbbuxRBmygsrgBPJJIG2bZ7GZVWc9UbTkcWh1yqq PFT7YIuVzntRGLHydITRNYMgcdhz0Hkv7QW0sdItJP8vZlQ0Dbds8TuleTOWRKSg3274DXfQ0 F1e10EpJPvos9LyhXbWkDzEccvvpjf2CCnXMOq9A7/jLzLj6yn0ymi1FSsG31SG9OunYBj9Nz xKJZG/fNU6OpetFnioz74lftrGg4Gba5Riuzg5LQprirudgjP3CulY1C0++xKmxklVcm+Goiy UJ/IvZgRH28ULcrbR1cZhqvPbsGf4t+pxoOSsIwMblLFURuFFWlEfA2J8MCP0YlmqdN8vs+/D 7eoKAx2hs9aYJMF9/op/s2P2tuLaRDlg60Rp8qm6KOBMmEfKQUwDIwifJNYCUqC1QSrxbMwrf 8sKnTKOEle2zUwO9FYVV0t0JgVi/f6UDslWQtkUP/gUGdP1s+KKt7tpTBIs+TqQnD2wUgqNEa ouQfCsY9iCv6JVbFvAFoyAvjsrJQAbQq3Jqw1nZPIjeXEYlLW4fXV7f6JHy2WzfwwDxSs2H+S oD1dX/xv3cTPrMZMzd7bm35/PEw0/LL9o9ng6Jg9TMDZjyOEOmmZfXuMB6vy4MunFEtOyDRug 1RmTKLpyfzbfAxDjAHg7YsPgO47EZfupuBje14MSrZxug5jF0NZJq3+SmHbyq3bhzoXhtwCwJ P3NWRFSnfPT2TZtDkCV2hCIXQi1OtGNCewinpO3wsvAVMVQjLw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.131 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Aleksandar Markovic Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic These FS_IOC32_FLAGS ioctls are identical to FS_IOC_FLAGS ioctls, but without the anomaly of their number defined as if their third argument is of type long, while it is treated internally in kernel as is of type int. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-3-git-send-email-aleksandar.markovic@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index c44f42eaf4e7..4fd693984e6a 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -140,6 +140,8 @@ IOCTL(FS_IOC_SETFLAGS, IOC_W, MK_PTR(TYPE_INT)) IOCTL(FS_IOC_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC32_GETFLAGS, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC32_SETFLAGS, IOC_W, MK_PTR(TYPE_INT)) #ifdef CONFIG_USBFS /* USB ioctls */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index f68a8b6e8e18..964b2b458dd5 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -920,6 +920,8 @@ struct target_pollfd { #define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long) #define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long) #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap) +#define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int) +#define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int) /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) From patchwork Thu Jan 23 08:22:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347019 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E99417EA for ; Thu, 23 Jan 2020 08:24:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E3CB24125 for ; Thu, 23 Jan 2020 08:24:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E3CB24125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXmW-0002lL-Sp for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:24:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55912) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlI-00011Q-0b for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlE-0002o8-Tj for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:46 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:45245) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlE-0002hi-Jq for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:44 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MS43X-1j1OAp0ytf-00TSBm; Thu, 23 Jan 2020 09:22:36 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/17] linux-user: Add support for FS_IOC32_VERSION ioctls Date: Thu, 23 Jan 2020 09:22:15 +0100 Message-Id: <20200123082227.2037994-6-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:gADahtYlfl4hprY4xyq4f2nsq+4iPSHC+rkl+9yB9X/no2DySL7 lc43L4h64kQZRax8uTCq/WXFnl1AUSor3RfaXMc5gvY3mUFo+0Ob1orAtk3t00J9K7Au6yj T7+FnZo0CYR3kcTGFG1ZvAyNqK6Uoer+Ru3bN2TcbTfzbNS61pkmu7KZdcaNXsDFtYvhPX2 I6uN/8uq9zC5Nqx6GhCtQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ugM7vGuRw2M=:2vSXN+4leZhkZmGBH9uBWT ndFJGK0L80hu8/BZVEIpERCuUe3WezvxYqFpsJB7OeTy1KAXJC6CS0gs7zJHpCiW/jz2y/hXJ bdPLGRARRbiQB11QPJB91DhVf4F9ePHxHB3iic7ehwXTaJhdPOU8sKuIji6lqoT+eZzCg+lzI QrumpCeGxCNT/fJvBLmTXuEMeoaXI2DwEaAMsiKomCjxK7RzB/Bno0t8coWE66pcsFJofoVYm wM7cqFQi2Vhbp+YOHLYzPzIp+0O0FiPN8+Onn0+/D1Qynr426yxfAhEBYNqQbtNf9u6mAhYqZ ttX4N5l0LSUWnBjiK2EG8sJOTC3KGbHBOdlVl8fHRtNOPBmfDKLM1wrMZ1acNEDLijXKoD4W7 vPqEOaLlfxEkmko6eZFB9PYBfgPLIgPPtHE88+er0OB5dUKO7Xhso871emgnN+ysJbd4PsETd MatedhuKrN6czZRMrg+jqa28wwMUoeb8X68ztjeliRnStRRlF/45LBCHU29yidp+6sHGpydqP Lg5Be6xB3AlJzNNL7VbIywskVNE8fqr0pXAZZMSsCAjjU+WyCuK0uPvnDCCfNIN2pYmPEDzA9 BIaIK1XB2VIx8+xqzyuMdDTtgfWQXI/K2BVCXnGXyM4jWXv2bcByz2qwjnGqXuUcK4F1bTmag NUfCgTVsLw79F9AeL91rAeP1APuB6ybxVmYWXLN8mgQcI093/O2QcPo1Hcv7LKzAqmxMZrEdn Ji3NBYXlol2Pc05ETzTP5eitDIP9V7+BG2aLTg1v0dq/8zXtwLEC+WSyWCcPKbl4ICh+NVYF1 BLrDlbpiVhg8bRYfGG9Vs6DZ2zSSZ28Hmq0NwMNOO45JBPgxzI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.131 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Aleksandar Markovic Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic These FS_IOC32_VERSION ioctls are identical to FS_IOC_VERSION ioctls, but without the anomaly of their number defined as if their third argument is of type long, while it is treated internally in kernel as is of type int. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-4-git-send-email-aleksandar.markovic@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 4fd693984e6a..3affd8814a86 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -142,6 +142,8 @@ IOCTL(FS_IOC_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_GETFLAGS, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_SETFLAGS, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) #ifdef CONFIG_USBFS /* USB ioctls */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 964b2b458dd5..a73cc3d06790 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -922,6 +922,8 @@ struct target_pollfd { #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap) #define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int) #define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int) +#define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int) +#define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int) /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) From patchwork Thu Jan 23 08:22:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDD756C1 for ; Thu, 23 Jan 2020 08:31:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9319124655 for ; Thu, 23 Jan 2020 08:31:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9319124655 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXu2-00054t-7k for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:31:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55969) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlK-00013E-C6 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlI-0002wm-Ak for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:50 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:35363) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlI-0002ul-1O for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:48 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N4hj5-1je0iJ2zzz-011g10; Thu, 23 Jan 2020 09:22:36 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 06/17] linux-user: Add support for FD ioctls Date: Thu, 23 Jan 2020 09:22:16 +0100 Message-Id: <20200123082227.2037994-7-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:gBkw/jmdz/LtmzTMQt/NU0YwDNRHoYbQ+Zm9Z2cq50ywGcngvF4 IG0GSEpMp7wC+C8bBVlu9D9KtLjqVKf0lwEbG+IQMnm6UsgHa1SksnCPKO8Qr2d5vrw7NcV Jq9lkY/K3BNsjimXi8rljwc+DZBFqQRGve689AkxqeXUAFisAn+JDKnUjaOXbfmyg0z/Nf0 zjrV0H/YYJEYJ0j0qSb5w== X-UI-Out-Filterresults: notjunk:1;V03:K0:JIla6PNb3nY=:FpT59qBYzckyiP7VbCW9CT 0mOoCoanUH1/xsS9qMPST19zZKueaNN2nZloAi5BKkvlY6jee9axJguEKEMwIrdngZfZoc/1P 7sdBRrExKSvvQRYT+kPx0x1NZ6lzz0kaX06O1v62lRBvt347rwVIl/pWmHQyXXjNQ36PPWPFQ 5fXxOuQH/btVONojV8vD2H8kjx+oPcx7livKGMFU2iwJZZkxvSZf0LfLAIijJaP1tByV1KFPI L7wYI6BN6hZMYcu7LXnMgT7GSWhOjdSzxQcccrW8huJ2IwX79/yhAa6Mnd3morWx0EXHIcnbY +R+WitynK05yPrhteVC/1/lq4AOMbHJnYoDfwvB3r/2ln2Tx4A5jG6DmxysqiKQAUzM70Jv03 u0OolZLA0SVb3ZdMMk0KpE32GVM/xKDYxySDZGN6iF9AGaerjg7GjAkDWfz7n7Z4vum2FOFer 6bV2wdEfFHlLNyN3yMl7u0Y1ahqINeA5H0Nfsvns0E2IbkBLnxPCS+bscYvg0Dlwu/YCXUQ1e C0z5bsXx2epKKprinmihIQ5vRI8Li0yIlJ4wmtqfXKKxk/eN7hL3XsHE7gKtkJpvPljfgHGbN NPqF9EWTeJZoeRo6VJdHuQK7+nt3ZM/iOH5QNlmXH45VpM/rgVb1tZ5GIq6tNrBjokRxHKOPD 6jU3r+50XHGJm7shCU8wJcE14U5Q6JwMRXCz0GvS3h2na/1JOir1/lBDYKyXfUSP+HJZcbCuR J01j/0hI7IgqBiDwz6hTuJQ9uReZRM2+yK1kyPuxMw9bcA/Vall6PNwrXn5ndJFfBhao5rizO qISnnFG2U4BUy88d6OafLkiLjW2GcBGTGgVxqgpgItVwANWj44= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.135 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Aleksandar Markovic Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic FDSETEMSGTRESH, FDSETMAXERRS, and FDGETMAXERRS ioctls are commands for controlling error reporting of a floppy drive. FDSETEMSGTRESH's third agrument is a pointer to the structure: struct floppy_max_errors { unsigned int abort, /* number of errors to be reached before aborting */ read_track, /* maximal number of errors permitted to read an * entire track at once */ reset, /* maximal number of errors before a reset is tried */ recal, /* maximal number of errors before a recalibrate is * tried */ /* * Threshold for reporting FDC errors to the console. * Setting this to zero may flood your screen when using * ultra cheap floppies ;-) */ reporting; }; defined in Linux kernel header . Since all fields of the structure are of type 'unsigned int', there is no need to define "target_floppy_max_errors". FDSETMAXERRS and FDGETMAXERRS ioctls do not use the third argument. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-8-git-send-email-aleksandar.markovic@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 3 +++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 3affd8814a86..2c3d798842e4 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -114,7 +114,10 @@ IOCTL(FDMSGON, 0, TYPE_NULL) IOCTL(FDMSGOFF, 0, TYPE_NULL) + IOCTL(FDSETEMSGTRESH, 0, TYPE_NULL) IOCTL(FDFLUSH, 0, TYPE_NULL) + IOCTL(FDSETMAXERRS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors))) + IOCTL(FDGETMAXERRS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors))) IOCTL(FDRESET, 0, TYPE_NULL) IOCTL(FDRAWCMD, 0, TYPE_NULL) IOCTL(FDTWADDLE, 0, TYPE_NULL) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index a73cc3d06790..48de76145f0c 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -899,7 +899,10 @@ struct target_pollfd { #define TARGET_FDMSGON TARGET_IO(2, 0x45) #define TARGET_FDMSGOFF TARGET_IO(2, 0x46) +#define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a) #define TARGET_FDFLUSH TARGET_IO(2, 0x4b) +#define TARGET_FDSETMAXERRS TARGET_IOW(2, 0x4c, struct floppy_max_errors) +#define TARGET_FDGETMAXERRS TARGET_IOR(2, 0x0e, struct floppy_max_errors) #define TARGET_FDRESET TARGET_IO(2, 0x54) #define TARGET_FDRAWCMD TARGET_IO(2, 0x58) #define TARGET_FDTWADDLE TARGET_IO(2, 0x59) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 4e3698382629..e4e0429637c5 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -261,6 +261,13 @@ STRUCT(blkpg_ioctl_arg, TYPE_INT, /* datalen */ TYPE_PTRVOID) /* data */ +STRUCT(floppy_max_errors, + TYPE_INT, /* abort */ + TYPE_INT, /* read_track */ + TYPE_INT, /* reset */ + TYPE_INT, /* recal */ + TYPE_INT) /* reporting */ + #if defined(CONFIG_USBFS) /* usb device ioctls */ STRUCT(usbdevfs_ctrltransfer, From patchwork Thu Jan 23 08:22:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347041 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE5EA921 for ; Thu, 23 Jan 2020 08:29:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AEBD524125 for ; Thu, 23 Jan 2020 08:29:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AEBD524125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXrj-0002K0-AV for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:29:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56003) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlM-00014u-3v for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlK-00032B-KJ for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:51 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:34085) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlK-0002zI-Ae for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:50 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M2w0K-1itRpJ0jHw-003QiD; Thu, 23 Jan 2020 09:22:37 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 07/17] linux-user: Add support for FDFMT ioctls Date: Thu, 23 Jan 2020 09:22:17 +0100 Message-Id: <20200123082227.2037994-8-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:T6e1aRRRGjwso8DsyU83AP23O2FYyJR89ofrWkTtCHWrLkPdLhy p2WCAYG+OH51h4o3GUMr6fvWbh2pBYhTHgx7bYv4QlHxfMN1ossVoiuRtRb9uRun5DnSktC TBCm/ndHE95MBb0nX+T+8AjhgaE0E/omeG5+w9QBH/G4MxQZ6Y24KZol11RwDFDZY8zD5hL mujA3caCpapQG5sUvyThA== X-UI-Out-Filterresults: notjunk:1;V03:K0:aeHXt/K6uuA=:5K/3ClrR6tUUeqj1/WBuv9 MD2S7mhHlqHcMio3hRxpJg5fgz3nLa+2lLLqwBCGjbFjlyK3Wm3bNyVGAAfF5VU7G7+SyQe7B gDMjWOE2CJhYRRMkHi229e/GbH3PdmDJBQNBJv9x+h3/ng9wQAPEM8oTqId1vGjseEeuz0YnN UIvDYLcUrlxPUuDVK4KZv83HsYOlwqbiWv/dOCNG2n1Il0tEX53Ki3ug1SknOvKjnaE55nU9o isNyUm5ZbzbCH/AfuWLOy+j93OeUZVbuhhcPfq5+onlT0KtCb3mfKqBsgGB0XSZLF23TRzp45 j17co/OOSvi4zpBnJmVgeSJ0TTibLdtiNF6I69ltdTqEV2hDycJqANZX88/iGIw9F48zRHbyK SEc4N9OenHOOFAJXltqnKBJ75R85IqDK1WCfxoxBX6Gp+xNnVPw6uiSuuh8FHyPRFQdL01O3M YU8g2NI+ZdYaFmdw4F5yN9Pqo3AhkiMMo1I+SyXWw7wNFuDG+fFi1jh+0Uh4JveMm9yXIjqpO nwVuNWRedfS4zHSX7GY93HphdagoBYQOTxM/ge/c65Z4nyKqxHLYTmKlw/N5dItXy+G4Mj5vE X2C/rdXImwUp7nmI8DSm11jXOWyeKXGlPgTLd1YFkDkumakOEMvtgZrO6xLcQQoi1g/dexv1R 6PZtMlpl2cHRx6Qh9ncb59BwDwnqjDY4nx9GOgV1J2unifPM1rBNr6m1zIRjWT4YpopCC4LCe RryLS8Uh4k0OGfD3RE11aKqwlegtRQO1H7u4/+5MJcPpXFL7uowuBpK3ELn9nGqK92cmH/qji g9AYHD8cVBUG/Pv1mC1JPh5gZc/dMa1+cNtydSp1L9vKdndH0E= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.131 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Aleksandar Markovic Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic FDFMTBEG, FDFMTTRK, and FDFMTEND ioctls provide means for controlling formatting of a floppy drive. FDFMTTRK's third agrument is a pointer to the structure: struct format_descr { unsigned int device,head,track; }; defined in Linux kernel header . Since all fields of the structure are of type 'unsigned int', there is no need to define "target_format_descr". FDFMTBEG and FDFMTEND ioctls do not use the third argument. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-9-git-send-email-aleksandar.markovic@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 3 +++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 2c3d798842e4..29969e2f2f27 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -115,6 +115,9 @@ IOCTL(FDMSGON, 0, TYPE_NULL) IOCTL(FDMSGOFF, 0, TYPE_NULL) IOCTL(FDSETEMSGTRESH, 0, TYPE_NULL) + IOCTL(FDFMTBEG, 0, TYPE_NULL) + IOCTL(FDFMTTRK, IOC_W, MK_PTR(MK_STRUCT(STRUCT_format_descr))) + IOCTL(FDFMTEND, 0, TYPE_NULL) IOCTL(FDFLUSH, 0, TYPE_NULL) IOCTL(FDSETMAXERRS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors))) IOCTL(FDGETMAXERRS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 48de76145f0c..b3acf85a6b23 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -899,6 +899,9 @@ struct target_pollfd { #define TARGET_FDMSGON TARGET_IO(2, 0x45) #define TARGET_FDMSGOFF TARGET_IO(2, 0x46) +#define TARGET_FDFMTBEG TARGET_IO(2, 0x47) +#define TARGET_FDFMTTRK TARGET_IOW(2, 0x48, struct format_descr) +#define TARGET_FDFMTEND TARGET_IO(2, 0x49) #define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a) #define TARGET_FDFLUSH TARGET_IO(2, 0x4b) #define TARGET_FDSETMAXERRS TARGET_IOW(2, 0x4c, struct floppy_max_errors) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index e4e0429637c5..8ff78a625ace 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -261,6 +261,11 @@ STRUCT(blkpg_ioctl_arg, TYPE_INT, /* datalen */ TYPE_PTRVOID) /* data */ +STRUCT(format_descr, + TYPE_INT, /* device */ + TYPE_INT, /* head */ + TYPE_INT) /* track */ + STRUCT(floppy_max_errors, TYPE_INT, /* abort */ TYPE_INT, /* read_track */ From patchwork Thu Jan 23 08:22:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347023 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E6AA139A for ; Thu, 23 Jan 2020 08:24:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E45024683 for ; Thu, 23 Jan 2020 08:24:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E45024683 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXmy-0003LX-Nm for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:24:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55925) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlI-00011Y-D5 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlE-0002nn-S6 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:48 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:36769) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlD-0002e6-4T for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:44 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N9MYu-1ji7aL2gYW-015Eej; Thu, 23 Jan 2020 09:22:37 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 08/17] configure: Detect kcov support and introduce CONFIG_KCOV Date: Thu, 23 Jan 2020 09:22:18 +0100 Message-Id: <20200123082227.2037994-9-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:vw/gO8wDzJ24T7wRq8a05ei+gcep8mZSfAVtR0HjNqe48tPpztH hYMGYdsVqSshliBuwcFtcN9dt4luvoQOL3ADpX1c/UYp2j5aMrkhNrk9/lAGTAkXrGoCq8K cwtCxGNPyXRWL+8YWnbSX2piGA/N+2/2HymRzBrw8dAy8n41DGUuW7AUbeLbFZ6O/O3DIWh dVYS1Np5ZZrZHuCc3uOsw== X-UI-Out-Filterresults: notjunk:1;V03:K0:2L5W3dzSbsA=:XYPGBPcozcxkShAWDaUIBz MZhuq4YDx4X61FnRZz7S3pL8IULSdhJJbN6IwKOkWbugWUb3fVG6r6kN0bmMdxUxnnTk00Y3G KvzlQzDYAwUKxvr+hVCi1tLbgsPbzpZpXXd7k9DlUpKzcbkHUm7XgLH6Lq8mu1pbYBZ3Wc6d3 w5YQB7HqTIkDMjcAkJVvDrsB/VB+KO9GawiJmDE8qoIB72kDD3LGGYvkBVxlFolzd4tZ3y13U F8QKradllu3i+EyL1GNDCp0fIPrb1dXGBLIgSH8baUmFzab3IvEFTBr/gujDfvwf3mOi8Y8kv NNqRFxCsYrkQ1n5BvA+G7yu+vUD0RJTqgVKJ0030JpiDZKGiVIz6v85SPDqQ8FNu/167xR9FX huYNGuMD/4aPaGq2hSos3AsyO2quNibQr0oZv0X/hEq4VE7ia344/khzLYK4bzg9W8uxyasAv TQ/o1dN5ac+HnNW9oPb+CXGrBxskOWUAPl5cxb9Y0GfUzrARfdV8cCnT5Fq1AjVYStEfx19w+ QyEkySbVAX8Ou3pg+jzTmnV9qN1028pkXJjFUUFAB2/4yy/48dqMCkegBpiUhLyMw3NU95Y0O X8q6cMEXTbSAa0mUr9vZYgSPUIm+2dofdpTM5Y++X3IH/fYtwiRN9Zb/dWUQAIK1F6Z3jfZtk 3WHQNvHeer0aHsCKNK6bK1TXtYwkxudm4Xg3nrWWs2nHOlzdpq22iubetE+7JepAsVQyec7Ti bY0Y48uJmA230mHenYsPqOFhH7YpXUG5dPbQV8ACr+rBnH20xRRBqrwOlBY93g5d+63u4oWAb Hj+URYc6rRx1Ezfsv8oNoAXr5GEHwJpPJkEN9DQ2Qw46kk9Ozw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.133 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Aleksandar Markovic Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic kcov is kernel code coverage tracing tool. It requires kernel 4.4+ compiled with certain kernel options. This patch checks if kcov header "sys/kcov.h" is present on build machine, and stores the result in variable CONFIG_KCOV, meant to be used in linux-user code related to the support for three ioctls that were introduced at the same time as the mentioned header (their definition was a part of the first version of that header). Signed-off-by: Aleksandar Markovic Reviewed-by: Laurent Vivier Message-Id: <1579214991-19602-11-git-send-email-aleksandar.markovic@rt-rk.com> Signed-off-by: Laurent Vivier --- configure | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/configure b/configure index 557e4382ea87..d91eab4d65c4 100755 --- a/configure +++ b/configure @@ -4761,6 +4761,12 @@ if compile_prog "" "" ; then syncfs=yes fi +# check for kcov support (kernel must be 4.4+, compiled with certain options) +kcov=no +if check_include sys/kcov.h ; then + kcov=yes +fi + # Check we have a new enough version of sphinx-build has_sphinx_build() { # This is a bit awkward but works: create a trivial document and @@ -6874,6 +6880,9 @@ fi if test "$syncfs" = "yes" ; then echo "CONFIG_SYNCFS=y" >> $config_host_mak fi +if test "$kcov" = "yes" ; then + echo "CONFIG_KCOV=y" >> $config_host_mak +fi if test "$inotify" = "yes" ; then echo "CONFIG_INOTIFY=y" >> $config_host_mak fi From patchwork Thu Jan 23 08:22:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347033 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B7EC184C for ; Thu, 23 Jan 2020 08:27:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A26824125 for ; Thu, 23 Jan 2020 08:27:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A26824125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXpb-0007MQ-QJ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:27:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55932) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlI-00011l-Id for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlE-0002ne-Rw for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:48 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:56565) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlD-0002h1-5b for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:44 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MVe1U-1j4P740RjI-00RW7J; Thu, 23 Jan 2020 09:22:38 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 09/17] linux-user: Add support for KCOV_ ioctls Date: Thu, 23 Jan 2020 09:22:19 +0100 Message-Id: <20200123082227.2037994-10-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:zNfPndWnTfyMu8W8Zt6FV95lB+oI0aYtu0oTtxqSMeEEo8Hymj8 5v7iyn5KuJoof1XG5fipPYK4b0f+h3zXxOckDsGEFybjoRxfQWtjG9dxOXnP7SHaIIU4xAv 8l+p6aSxxmWEp1dnM8UBKPJCbEm74KJnEGX0t72NKKIWli4f174SAUtB/5vFBHpxlbcu3O7 7xNG0R2ocXmqsEKr1zxMg== X-UI-Out-Filterresults: notjunk:1;V03:K0:NfN7sH84tDQ=:BAk6VId1vOw+vrviRC0Zxv GO1H58GuhGT7rvlVEwTVG3ZKDHkEpraLIvwImOzNInJNfFQmkFR913hPyi4nRL82N5j1bdFCF eGsAM3xvr29fQ8NXVFBvW9CF7SE88L+jH0VGBtBNntyTvkJP3KFGVF2MBy3qnIXLWA2WWsXLc lJEMs03ACp1CW4HNvFZjaUW4J78IfWR9l271ett7fauDr1Pj/fxer3w1lKcsfCmxef80dhOMS 6ebsPnpfmoYc/Gt+AV/ooBLbJStHv8lSTTz4OstJi0d2MKrhCZ4SxZ1EhP23thpkOBn+kN0BN ArQ1JEPWogL9NL0GRFDxrVVryjewHJHahoN5NtOGYGVrNcfChwJmx5AjPxYrXboXWF6DEJ0vV ai/U9X5zSLwRLc1SWEua8FfIXCnYeQVEJ2IMIafdsM+HiYP14sr3koGnQfUkqj1iMtD6zHbkE xnreMK5yh72AC2kBs1WKfhdKrX7GR3cExeG5R1pkasOONmR7wJJ5KgFzU75Sn2HcsXG3inQOS qVBT9pD5Dz8At4yySrAjVD04lXtLzXNmioLEeuZinoHnWmhHNUaYVVGY9GCdZaTT7EfZ/zg0A PqD+uv8VgUHS6p75F88mB/nJ5KSFYFmsRN2mScbsn2vbJmeV0XW2Gr3Ich27EjhsgERWqPLPB Pg01Z19Xu1FQYuqNeGHbZo+hJd4Ymj/bbGKiBof5ZrmoI2ARpQ7pDjBJ3xMTgGXeBVHGXr0t+ 7EPgpKfQzw6s91rNnfF9e7+9JteGBGCackXJeUKP2E0J5fCb7wdOwX/Rc8k/Uwi0n/ZZxIWLX fyOg3+bGwadqF6BM4d6n2FpYKDc7jzKtICUkqn+zAIgvggN+7o= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.133 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Aleksandar Markovic Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic KCOV_ENABLE and KCOV_DISABLE play the role in kernel coverage tracing. These ioctls do not use the third argument of ioctl() system call and are straightforward to implement in QEMU. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-12-git-send-email-aleksandar.markovic@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 5 +++++ linux-user/syscall.c | 3 +++ linux-user/syscall_defs.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 29969e2f2f27..6220dd8cf791 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -534,3 +534,8 @@ IOCTL_IGNORE(TIOCSTART) IOCTL_IGNORE(TIOCSTOP) #endif + +#ifdef CONFIG_KCOV + IOCTL(KCOV_ENABLE, 0, TYPE_NULL) + IOCTL(KCOV_DISABLE, 0, TYPE_NULL) +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 249e4b95fc9f..c5bda60b45de 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -73,6 +73,9 @@ #ifdef CONFIG_SENDFILE #include #endif +#ifdef CONFIG_KCOV +#include +#endif #define termios host_termios #define winsize host_winsize diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index b3acf85a6b23..7b0b60d253d9 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2434,6 +2434,10 @@ struct target_mtpos { #define TARGET_MTIOCGET TARGET_IOR('m', 2, struct target_mtget) #define TARGET_MTIOCPOS TARGET_IOR('m', 3, struct target_mtpos) +/* kcov ioctls */ +#define TARGET_KCOV_ENABLE TARGET_IO('c', 100) +#define TARGET_KCOV_DISABLE TARGET_IO('c', 101) + struct target_sysinfo { abi_long uptime; /* Seconds since boot */ abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */ From patchwork Thu Jan 23 08:22:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347037 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3BEF0921 for ; Thu, 23 Jan 2020 08:28:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BE3A24125 for ; Thu, 23 Jan 2020 08:28:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BE3A24125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXrD-0001VI-6M for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:28:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55971) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlK-00013I-D3 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlJ-0002zM-41 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:50 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:34195) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlI-0002wf-Rm for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:49 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mbzhv-1jT3QX2T8x-00dabu; Thu, 23 Jan 2020 09:22:38 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/17] linux-user: Add support for KCOV_INIT_TRACE ioctl Date: Thu, 23 Jan 2020 09:22:20 +0100 Message-Id: <20200123082227.2037994-11-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:hr4ZMo0VmkvhhZ9Wuf/ByxXTOlHeIZCcmCXUKd0fSWtiKPYF70e JdfAxdjmeuirhP+Xpv4wxA0WcG6xN3eWcodjEuu/72OVdVnjXIa/iICI45QNgYGEByT8Siv QARlg7qr+Xa9pB6+PmF+Zglp2UpCdOf4H0Ik63BqjAsdy8/q205U0OtsxH318Rmdqp5j4FV bf/jiGMoMkAohJHg2ON8Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:61EkKJ01Mio=:j2eMW1riqemOYwbtVA4I8H r7UtOnrU4jnOrQuR09kRCVe/341Vj/GdKYDKP3VItUCkY4/JPAbg35rzykC6ADILlNes/mnCZ Bbi+QOi2xIXIFyLSNI5L4BbHkYTewh12StXizpHZqEPGcAN/dBtms1Q8viUThjS9Z8xqfgGlZ t+5CG2iquvI+lyrub524G6FwkpDYthkvjb1ETffodyCHqMe0dwuIjeZosV0UDfnxGh6M0pkCZ c+zOURC7Sm3TRmVb0cMtz6yOuUo/mfRyajUeO5/k7Yx1JD+yoU4q9YH418uCF1hOoWSM4y+gY 2P+iEwm594lrQHqZnsDCVKM0PuplKKVmD5CSzrgxwF4Q22RD4gVJm3Tkx0Q2oYvOsNvESRzEG FSxcX5ziVHCU2A19+WfBDUTudfMuY9XAqs72hHnhwBgmGBVp7tM+dNGz59rQ/WOnRBVFEO+y+ 2vlXea76ng9OJZbC7TTjzkhVkPegnxdiS3XsI2e2cFGgE7bhfTB/xaaTO/EuutOmcNJFa4ki4 6FaJcNXui4vjN1HMdp0ra7sX6MDPXx7rI+RnDZsdtlNYV51seNgdfd/PNJOA0k3y0qx+sFKK0 xoqxFSFB3SUBMKsArUggL+XFb2weNX/wjCf6ISSOyKcAtOmGGsHtEbIOlJuvfEj8VgWRErnMm XK9pFHsSZ37Y5xWoQd9p0R3sUhdAmHSk4tZE1mBUw3LKHOC9Z//fdmb0l+xTXCiEG+/rQjUjU 4YmdI8RxjQdRWaRjn4WdPMMYMnupmLUXeOcL4gzH4uXPyZdJhhWNmpqwvjcMt6NOGaa9T8D8j jK5ltTZIpQZ8H16vuGhTytKkGr7nKnx46Gp3RvvlTeo+0Dv5jI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.135 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Aleksandar Markovic Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic KCOV_INIT_TRACE ioctl plays the role in kernel coverage tracing. This ioctl's third argument is of type 'unsigned long', and the implementation in QEMU is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-13-git-send-email-aleksandar.markovic@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 1 + linux-user/syscall_defs.h | 1 + 2 files changed, 2 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 6220dd8cf791..23f6d3feb5db 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -538,4 +538,5 @@ #ifdef CONFIG_KCOV IOCTL(KCOV_ENABLE, 0, TYPE_NULL) IOCTL(KCOV_DISABLE, 0, TYPE_NULL) + IOCTL(KCOV_INIT_TRACE, IOC_R, TYPE_ULONG) #endif diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7b0b60d253d9..fb8318d12185 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2437,6 +2437,7 @@ struct target_mtpos { /* kcov ioctls */ #define TARGET_KCOV_ENABLE TARGET_IO('c', 100) #define TARGET_KCOV_DISABLE TARGET_IO('c', 101) +#define TARGET_KCOV_INIT_TRACE TARGET_IOR('c', 1, abi_ulong) struct target_sysinfo { abi_long uptime; /* Seconds since boot */ From patchwork Thu Jan 23 08:22:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347039 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B12A4921 for ; Thu, 23 Jan 2020 08:29:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9140A24125 for ; Thu, 23 Jan 2020 08:29:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9140A24125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXrS-0001ur-To for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:29:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56094) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlV-0001NK-EC for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlU-0003Ay-9K for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:01 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:45953) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXlU-0003AA-0c for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:00 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N3KgE-1jdBtt2N6Y-010IyB; Thu, 23 Jan 2020 09:22:39 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 11/17] linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl() Date: Thu, 23 Jan 2020 09:22:21 +0100 Message-Id: <20200123082227.2037994-12-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:eodUeUisqAWTjs8Z6zmqWWfREn5jIMk2MN+z4os6X6525iNoGp2 7LvDCVFEcM9e9ytPZrQ7rR/GJxcxbadcfPpwWnD5NoMdLbZifmNveNgX/Ng8hY6vTzdKB5y asucmhijVP3swoD6sLPf6URHiskM9AilVKBqax2NVvX3vFGGvrOR7o2C3WbqhVq9B0B2ofk ZSUGV32eXbXTFxcEabICg== X-UI-Out-Filterresults: notjunk:1;V03:K0:vjhQCSNrnj0=:epYK75BkDWtyB3unix3kVR jR0uYmRDDJXW4CgitDGstporfbIqpwS0YlJjKCwPhVayRacLd3Ss8iJIRG9ZRELOUXNZX+sqP t0nMaBFBAHsSgYSeEnbaaj/Wo1qQLm6gA9YL9qD5RE8uLOAVJT4DG8APa+j+H6qIjbja9UXIW AcXCOYpXp713db0zBkKsQdABH+6tdHcdRKKAKftTImTEMkcLeV0if3CGuLmd4vNiFSFftTLLN yMYZ6Chxj04ThvyZgrjvIIGKYnCJ/of4NCjGUo58dkmqB4OOgetou3yovsVK0paJrgNS2rAHz wUsRcOWh+XhpC25KySjmvCnYC8pERICBJdDjGBM1dfqpyA/2qc3B5K6Byoyp3+2DP30pkF/tZ Q69bwG7DbMIPu4Ndfs9aZBeof2j5jb6mvErOhLf6CxNVFOkWIEeL6eOv9s7eZXxykePeStTjU /IuxffiE+vp4nCKad407xe+IeG/ZnC7S6vG4bD6jJw3+UMd8SsWs4MShKFudsaOs7Ky9QGN1T KvIL/Ag+Kg565HhCaFXRZAb4aVpkZx5UW7JYx/9/GspICh8xSaPUXg+X0BZFEFWHqNNFBlxyM ty1QSEwf1NqiXJgmB9bjkuDu/yWTj+E4+OuMLer8zi8PRssnIO9gKGMqHnn5xP4Al4DqjPtTB JUXEwGDS5nfCD5VEPdat2J0iAczC+NsSdWbmAr1NecPLVh5mQ627VMMrfeQ60ay8iZ5OBSurL Knc+YMso97lflBZ/CC54kt/hi6nrkp8iijcT1Yr8y5hNJesvM6b3GCQTfyrvimPt7Fjs02Kn7 NALSXTIxkeJSTxgRF8bQWS3HfJlaccZdzEMxLlVQkgDrmw6NNHT/J+MHBopOFGM6C00AEeT X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.130 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta Function "do_ioctl()" located in file "syscall.c" was missing an option for TYPE_LONG and TYPE_ULONG. This caused some ioctls to not be recognised because they had the third argument that was of type 'long' or 'unsigned long'. For example: Since implemented ioctls RTC_IRQP_SET and RTC_EPOCH_SET are of type IOW(writing type) that have unsigned long as their third argument, they were not recognised in QEMU before the changes of this patch. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <1579117007-7565-14-git-send-email-Filip.Bozuta@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c5bda60b45de..bd2436b31007 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5178,6 +5178,8 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg) break; case TYPE_PTRVOID: case TYPE_INT: + case TYPE_LONG: + case TYPE_ULONG: ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg)); break; case TYPE_PTR: From patchwork Thu Jan 23 08:22:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2C2E921 for ; Thu, 23 Jan 2020 08:34:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B1D7324655 for ; Thu, 23 Jan 2020 08:34:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B1D7324655 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXwY-0008IL-RT for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:34:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56121) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlW-0001PC-IW for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlV-0003BT-3d for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:02 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:37613) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXlU-0003An-Qd for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:01 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MekrN-1jUhKH0B5Z-00apiu; Thu, 23 Jan 2020 09:22:40 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 12/17] linux-user: Add support for enabling/disabling RTC features using ioctls Date: Thu, 23 Jan 2020 09:22:22 +0100 Message-Id: <20200123082227.2037994-13-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:yMaEdQCad1FXyGHRpRa+gp1D7Uui/C8UVGYJSUGzDfxUAS98y45 ujZTAmNxh/jHTNZZJG5vvpKdR9k/Nxvqd2Bx8E7HX8Qw5PLVj0xXz3VKCmknn9w3jaNE7n/ 4pa1+l04lasGinjmhBmJkfpp+YO7rgKZoG8ouiLek5+e2sb+obNP/t1HCqv5G60qPWHyDK9 zFzdSpE9RMbPZqT574uhQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:ek035P64zII=:OjM9J4c4kGEQ9wMy/dK/gV ub23KNP6TYYC1KQCG93nTSlWyMDa+hASRusS0/egghSm7wavROUgS3h1IO9R2eoGpPSDFAuHf p5CQrpuR42oJr48y2s1FfTIMAGAejzrW4Hh8YfyzhqBx2SW/p8P/QcU60Oqffqn14jb/KTPi6 sCxX6uKX4JQonDbduYFk83yWcKx3UpDTsWd47NpJwB1IDszVYKllMzmgtks2MGivVks3ZR6aM HakpTi6O5YoQPoF3hFNTGVlXFQ91ZCl7wWgjtHTxHGV5wwUvAohcZqS+hEflqhVxVVSS/oU3i fKKhu7aMwMP26EhassctD8KA/btw3p7M3CZf138xfJwxhy+cU/FHmQNV4LS7rMDUaOC8mF08F XrqfW8MBbwkIQNKnPYaomukn0m4ObJa9lqpSH0GK+IhuKre9UAhYw+DMYw8LJ4LzWv9P+dVQq TGMAVPYY+LJLmekq/R+VZ+UWefnveVIavRGd/X7qW9l8NTP0kQYqXNi5ROEzn8GJP8QuYY8ql u6EVdsCjdBEXiGG055Y5X31UsIAu5FKNQnhf872Q4Y9gM9BhNp+jncUFQqZMR+6IXjWkFW556 ul0CuC2TGDdO9DYL86seFevpro571FqUUSD1nghIxRPHVFWnpbWFf1S9hGyOrGP++9DfLvsbN JAfXRwl7I4KEjm/H/RkvYKMrp50TnNJhBb/G31JJMQ3WkFNwZitdSa9P7meZGpcstCfg1SGVS hzaI4Y7XWdd7ZkUxkA1LTwgJJn/o8sgrznGGYi7cGs8N3ZLqkVv0ljnrmyBr5KXxE+vELPnwK 6/TkbbjpKdesk5s8wBbnEI7UaWZ0FxCaO5tVmZQ+alI9AxSTcaazJpFOhuJQxdpNp4n+6g6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.130 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_AIE_ON, RTC_AIE_OFF - Alarm interrupt enabling on/off Enable or disable the alarm interrupt, for RTCs that support alarms. The third ioctl's argument is ignored. RTC_UIE_ON, RTC_UIE_OFF - Update interrupt enabling on/off Enable or disable the interrupt on every clock update, for RTCs that support this once-per-second interrupt. The third ioctl's argument is ignored. RTC_PIE_ON, RTC_PIE_OFF - Periodic interrupt enabling on/off Enable or disable the periodic interrupt, for RTCs that sup‐ port these periodic interrupts. The third ioctl's argument is ignored. Only a privileged process (i.e., one having the CAP_SYS_RESOURCE capability) can enable the periodic interrupt if the frequency is currently set above the value specified in /proc/sys/dev/rtc/max-user-freq. RTC_WIE_ON, RTC_WIE_OFF - Watchdog interrupt enabling on/off Enable or disable the Watchdog interrupt, for RTCs that sup- port this Watchdog interrupt. The third ioctl's argument is ignored. Implementation notes: Since all of involved ioctls have NULL as their third argument, their implementation was straightforward. The line '#include ' was added to recognize preprocessor definitions for these ioctls. This needs to be done only once in this series of commits. Also, the content of this file (with respect to ioctl definitions) remained unchanged for a long time, therefore there is no need to worry about supporting older Linux kernel version. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-2-git-send-email-Filip.Bozuta@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 9 +++++++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 23f6d3feb5db..55ad47186dc0 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -69,6 +69,15 @@ IOCTL(KDSETLED, 0, TYPE_INT) IOCTL_SPECIAL(KDSIGACCEPT, 0, do_ioctl_kdsigaccept, TYPE_INT) + IOCTL(RTC_AIE_ON, 0, TYPE_NULL) + IOCTL(RTC_AIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_UIE_ON, 0, TYPE_NULL) + IOCTL(RTC_UIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_PIE_ON, 0, TYPE_NULL) + IOCTL(RTC_PIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_WIE_ON, 0, TYPE_NULL) + IOCTL(RTC_WIE_OFF, 0, TYPE_NULL) + IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) IOCTL(BLKRRPART, 0, TYPE_NULL) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bd2436b31007..d60142f0691c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -110,6 +110,7 @@ #include #include #include +#include #include "linux_loop.h" #include "uname.h" diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index fb8318d12185..fc3d79ab9762 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -763,6 +763,16 @@ struct target_pollfd { #define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */ #define TARGET_KDSIGACCEPT 0x4B4E +/* real time clock ioctls */ +#define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01) +#define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02) +#define TARGET_RTC_UIE_ON TARGET_IO('p', 0x03) +#define TARGET_RTC_UIE_OFF TARGET_IO('p', 0x04) +#define TARGET_RTC_PIE_ON TARGET_IO('p', 0x05) +#define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06) +#define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f) +#define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10) + #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) #define TARGET_FIOGETOWN TARGET_IOR('f', 123, int) From patchwork Thu Jan 23 08:22:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347059 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 858646C1 for ; Thu, 23 Jan 2020 08:35:34 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65B0924655 for ; Thu, 23 Jan 2020 08:35:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65B0924655 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXxd-0001Vc-HB for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:35:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56120) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlW-0001P9-GK for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlV-0003Bc-4M for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:02 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:44451) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXlU-0003Ap-RZ for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:01 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MSLAe-1j17KS291M-00Sd6n; Thu, 23 Jan 2020 09:22:40 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 13/17] linux-user: Add support for getting/setting RTC time and alarm using ioctls Date: Thu, 23 Jan 2020 09:22:23 +0100 Message-Id: <20200123082227.2037994-14-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:jEMpOTztBfFIlZTX4txnqWtGcJgh/znkufOiFsPSJx1XFo85WAM u77N0FRTgD7eEb/wrjtxl71rfYCGUdHaC6Qg1x7a+qx1Cbp0NRrUWGGb3y/5i97Apult8lE l4Yw9LznngNqPByu2hkhj+e3ERgcaV/LapaMuMUph9D1q195AJX83ObagUp5UFKfmCbIeqA WPq8+p3xYxdGtPIk7gpwQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:y1nnBkYg1nk=:F/xRqeTOW3bN7TOuuF40XX OK6pYTm2CaGJVqE8HLPuw63D2y2K3ttDMFN7lT2C05bnCoDGX83g1y8Hgnk9n/OGvmoJEc9w0 r99qCP3ADwXkJw3KtyjOYvY4JJyC6HlxAKtatYZjRu2SNAB/MCnyEbb6zyFZ2cqNlDks05j6d Spyhq7IEsARMA14g5MrDz3Dt4GO4R+sklQMEtdBu57d1PrXWKI/9AMlDZBb4vf7emd3co+pUf ZpoDU00U6gkbd3CwBNcyOEO/D3MpbpOm+nEcXpVDKHfoLx0OIcmJCdPU+SbWJVtu0j9wba4OB IfR5YlkZ45oWJW3BD9mIwlMeYwbCJS/r3JeU9yDBzKX0kxsho9VuBh3+sldDORtgHgi0tbx9F e4pSxh+N0eSAmnVWHCuI+0Z+xAT8yKt0nKSnHProU9qztYo04NjZDJYd5lUBBaAW73k6KaP4d ObXNhVN9qHoZBfBQHCsG2+4dSuIwvk8IB8U79cci85uuYFNLXUU7Ouvdngk3O1r3izzLpQVWb sWcm2NoCWStR2wKLVN7bME9q1YjTKTUtUnKnjLgvPrVqcB3sd/cMrZm57ZTFskiJEmHFu4swt wW14/Chy8JKs7vrPAnnrEPXfuzSOOhemkA7H3tlIbsNi9KmHgAXosyQEUb6tT9tlB7EoRd6r+ 6XaC7c6XSKsz38afzYiJrKWeN4+H90dEcOYZJMJW+En+WX8ZasAgrWQQu79MihZuT+GHfi/Pg 9nmJhcFWcz0P7ET7FU6VK9k8VezBqw7HFXZq98f+MfQ8KULLwT/REbKDcUNhRa84J9Y6GyS7S CaaPPAuiqhjzBKA/nPYgwiuQKOxkloHmG+wWqu/CCGRoei0j79FKNDpAEZz4k86MmBRvxyY X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.130 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_RD_TIME - Getting RTC time Returns this RTC's time in the following structure: struct rtc_time { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; /* unused */ int tm_yday; /* unused */ int tm_isdst; /* unused */ }; The fields in this structure have the same meaning and ranges as the tm structure described in gmtime man page. A pointer to this structure should be passed as the third ioctl's argument. RTC_SET_TIME - Setting RTC time Sets this RTC's time to the time specified by the rtc_time structure pointed to by the third ioctl's argument. To set the RTC's time the process must be privileged (i.e., have the CAP_SYS_TIME capability). RTC_ALM_READ, RTC_ALM_SET - Getting/Setting alarm time Read and set the alarm time, for RTCs that support alarms. The alarm interrupt must be separately enabled or disabled using the RTC_AIE_ON, RTC_AIE_OFF requests. The third ioctl's argument is a pointer to a rtc_time structure. Only the tm_sec, tm_min, and tm_hour fields of this structure are used. Implementation notes: All ioctls in this patch have pointer to a structure rtc_time as their third argument. That is the reason why corresponding definition is added in linux-user/syscall_types.h. Since all elements of this structure are of type 'int', the rest of the implementation is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-3-git-send-email-Filip.Bozuta@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 11 +++++++++++ 3 files changed, 19 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 55ad47186dc0..c39dd0128a60 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -77,6 +77,10 @@ IOCTL(RTC_PIE_OFF, 0, TYPE_NULL) IOCTL(RTC_WIE_ON, 0, TYPE_NULL) IOCTL(RTC_WIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_ALM_READ, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_ALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_RD_TIME, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_SET_TIME, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index fc3d79ab9762..dc36dd475112 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -772,6 +772,10 @@ struct target_pollfd { #define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06) #define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f) #define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10) +#define TARGET_RTC_ALM_READ TARGET_IOR('p', 0x08, struct rtc_time) +#define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time) +#define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time) +#define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 8ff78a625ace..bddc89a6641b 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -255,6 +255,17 @@ STRUCT(blkpg_partition, MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */ MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */ +STRUCT(rtc_time, + TYPE_INT, /* tm_sec */ + TYPE_INT, /* tm_min */ + TYPE_INT, /* tm_hour */ + TYPE_INT, /* tm_mday */ + TYPE_INT, /* tm_mon */ + TYPE_INT, /* tm_year */ + TYPE_INT, /* tm_wday */ + TYPE_INT, /* tm_yday */ + TYPE_INT) /* tm_isdst */ + STRUCT(blkpg_ioctl_arg, TYPE_INT, /* op */ TYPE_INT, /* flags */ From patchwork Thu Jan 23 08:22:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347027 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 32F8B17EA for ; Thu, 23 Jan 2020 08:26:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12AD124125 for ; Thu, 23 Jan 2020 08:26:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12AD124125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXoy-0006L1-IO for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:26:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56040) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlP-0001Ay-DS for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlO-000348-0f for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:55 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:60511) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlN-00033n-NN for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:53 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MlNcr-1jJk2n4577-00lo5U; Thu, 23 Jan 2020 09:22:41 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 14/17] linux-user: Add support for getting/setting RTC periodic interrupt and epoch using ioctls Date: Thu, 23 Jan 2020 09:22:24 +0100 Message-Id: <20200123082227.2037994-15-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:YZFoyKaAcNQl8z8+8Riz+v/ZSkh1cjwJxiVip/6CFHXtkDTTZQC N260pAY+36A3AoOpI71j59jpwdkZezVAfWpqlOERE7l1oLMEYhyDr+A3OBxLHxtut36l+/U bVJxBoEa9gnR4FLNvUrRax+ipz1Aqm0Vu6w0D3xH9UkJDVoRdODuXVnvoip7zQjIsjuccDt V6rRlmMtmsQL3AEVKn4VA== X-UI-Out-Filterresults: notjunk:1;V03:K0:RslzKrMcYFo=:6+jsLUaUEUptEZVU9oyXHK Ukg6s4GSlpp/7D5UDM6SetD0TPsL0ocRRX53IelD0CXlcFsTFGlJYyZTND92+lIDQNomkkGDo 2TDoT1lFPMuVwJpunY7Rxw3NjMwgCmotjBraFPMSLbFFjJBn6KYDj87+0Gx0zzYAB2BrkIqCk W/LEthJZxm/3vJNbIIzaXwDLFqgVz2aGptFEeQ7MtkkQqWt10nrRdELVZgPoZIpkezgkmKJY/ 5gvBOAqCpH4nby9ct5pzeKjgolT3FjPo1HqowLka/GB/aFgwjbor87p/J1X+xeA/kMtXQKIGu Xi3+zztpdwSodLi3u/CP7rOXiHRNb2FR5H6JDRch32SQjN/tH7szr790pktjHitZTVlt6yEXu y6YrlNGkP4U0X5pdkAkmrsk4I1mGSeAb5rkVZktTGwkWlegzVlLVgsexL29m6N8UbvqoHQSmN gDhIjtKMLn0HQbFSJrGJE3/BVQpOa8RdBAi3IByIg01uAolOX5j3i3BtYP6Hqxsy4TtZ3SAyD iOLOmB7EzmujW2nEbXg4Zc9nhbUPo9Xs/NNk9xFse0mx8t3FIbNyEy+khHId9s6DaLqhqgR2u fYT4gBRo05smkGt/yPLccUEnZ52DOjmkWeOysSD09Lduy97BNBgXuEAt6ihqLyBrnA9FDKWRq UoICJzPSudFLBkMNrx6efPM9kkfsULKy+JtUa0ViO49H9tB/MBnsLVnqrcg10/3Wa3/ROSyTk 1rCVn0XVJyeXbo//9o9DrCZjE57iXbVVe9HtqvuHBh7la0umSKBZrmqe55WEYpsyxYtEMb2Ln WEPd/mDr61VE64NZHe9fYzogTP6ugl2yW33LoHsSToqI1T8E78= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.131 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_IRQP_READ, RTC_IRQP_SET - Getting/Setting IRQ rate Read and set the frequency for periodic interrupts, for RTCs that support periodic interrupts. The periodic interrupt must be separately enabled or disabled using the RTC_PIE_ON, RTC_PIE_OFF requests. The third ioctl's argument is an unsigned long * or an unsigned long, respectively. The value is the frequency in interrupts per second. The set of allow‐ able frequencies is the multiples of two in the range 2 to 8192. Only a privileged process (i.e., one having the CAP_SYS_RESOURCE capability) can set frequencies above the value specified in /proc/sys/dev/rtc/max-user-freq. (This file contains the value 64 by default.) RTC_EPOCH_READ, RTC_EPOCH_SET - Getting/Setting epoch Many RTCs encode the year in an 8-bit register which is either interpreted as an 8-bit binary number or as a BCD number. In both cases, the number is interpreted relative to this RTC's Epoch. The RTC's Epoch is initialized to 1900 on most systems but on Alpha and MIPS it might also be initialized to 1952, 1980, or 2000, depending on the value of an RTC register for the year. With some RTCs, these operations can be used to read or to set the RTC's Epoch, respectively. The third ioctl's argument is an unsigned long * or an unsigned long, respectively, and the value returned (or assigned) is the Epoch. To set the RTC's Epoch the process must be privileged (i.e., have the CAP_SYS_TIME capability). Implementation notes: All ioctls in this patch have a pointer to 'ulong' as their third argument. That is the reason why corresponding parts of added code in linux-user/syscall_defs.h contain special handling related to 'ulong' type: they use 'abi_ulong' type to make sure that ioctl's code is calculated correctly for both 32-bit and 64-bit targets. Also, 'MK_PTR(TYPE_ULONG)' is used for the similar reason in linux-user/ioctls.h. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-4-git-send-email-Filip.Bozuta@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index c39dd0128a60..9e91eaae7705 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -81,6 +81,10 @@ IOCTL(RTC_ALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) IOCTL(RTC_RD_TIME, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) IOCTL(RTC_SET_TIME, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_IRQP_READ, IOC_R, MK_PTR(TYPE_ULONG)) + IOCTL(RTC_IRQP_SET, IOC_W, TYPE_ULONG) + IOCTL(RTC_EPOCH_READ, IOC_R, MK_PTR(TYPE_ULONG)) + IOCTL(RTC_EPOCH_SET, IOC_W, TYPE_ULONG) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index dc36dd475112..fcbb2ee9a387 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -776,6 +776,10 @@ struct target_pollfd { #define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time) #define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time) #define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time) +#define TARGET_RTC_IRQP_READ TARGET_IOR('p', 0x0b, abi_ulong) +#define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong) +#define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong) +#define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) From patchwork Thu Jan 23 08:22:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347045 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88ADA6C1 for ; Thu, 23 Jan 2020 08:32:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68FB424655 for ; Thu, 23 Jan 2020 08:32:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68FB424655 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXuM-0005V6-89 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:32:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56122) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlW-0001PI-Ix for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlV-0003Bi-6X for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:02 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:33623) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlU-0003Ar-TT for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:01 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M4ahC-1iwBeh1skI-001lkt; Thu, 23 Jan 2020 09:22:41 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 15/17] linux-user: Add support for getting/setting RTC wakeup alarm using ioctls Date: Thu, 23 Jan 2020 09:22:25 +0100 Message-Id: <20200123082227.2037994-16-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:zdqdDNWBwfZsV4R+PpOwZvnTVGLtTagEPRs4t94OcOAorDHakqu 8ntWNNwoeL2GTOACpBFsEzVMghWvKqCCI2M5hwxMyCvgyHRjgxtyxlDl/S+StMdUNkbe0ih RYGZGSpcK3FIrI4LQby7dp+eYXFcF/v2xcyXToaSFmrCtTc73kGrpukLGfmBFVL2YlwynWV wbExouApCNtaQMkc48Ugg== X-UI-Out-Filterresults: notjunk:1;V03:K0:dOQ0sgx6Riw=:izbcffJT4Gr119nlJIhRuP yyGpfSTSq/DsLFHAcRRXI6iZC6NrT9dF3HWjaLKTa4yRHeuCdQGdBdTSOvV7hHP034mUo7U/r g0Vrcg1sX2cAuTAQ9oHJ/7VMRPYXoZGATE09/Nl3xGl4tk2hFXweiRj0EKFiaU++9VBkEIOF8 Qv93SflVEhxyDmMxx1C0/g04IfRbSSRIIiH/35y0mfohX77iAqCQPX3zBsaJrbU+ke21mn9Ou 9AYwdkSrAy74TGHqHcnZSpoqGiLniLwwri1QfKqiDvdrYkUyJ2Nl3TCGWmfgybntYRsZVzyXe MJ//G1QvvecSou8KGTl0JEptFdNodw9yIKx71TujbnWV4KVtsC7Bo+Ekr2cSkowk7Izt3UWWm IuaAdjSwD+dsRqzSHMQtF+eqhukYEk8lwP4b1gLqRKleW/RlAbq5snru8WpWGfpAVt8PzIk2d 68EfO9Wr1D6PfAKkB43lxheTxwnh/GMf4O05FJIDWrPhPhEcjqZy0fALR70X0CjLcxdCU2ZX6 RqzXHES7vHwbuTCeMgIQ7o19RK3pL2Yk5DbKek95fdn05whoIy948gzRL+ZWqR9HcmBUN7SC3 TrxA8Mo5w0IUZJlCWV97J/1VFmOL1eZwUbnnVnXJcuMuNtiIwqoE5Gl6wx+gfVd6g44p2ZCKV 5BPou6jQxH/fbAqfl/bhLzgH6tsmA6qxZ5+3nvbby0rizUHM80iM0OuC5U08h+KZik403T/ij 4RM8MREd/+DfN7/8myqRgJYISlH8LgveSWIHX0pOHC4Zt68G4EII+BD/Yxu8X17BZ3GuPU325 RtwAwx1jKg6nAk99uR+H4CeXfTYnuANf3HjlE6Wl3jDQxR2fQU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.133 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_WKALM_SET, RTC_WKALM_GET - Getting/Setting wakeup alarm Some RTCs support a more powerful alarm interface, using these ioctls to read or write the RTC's alarm time (respectively) with this structure: struct rtc_wkalrm { unsigned char enabled; unsigned char pending; struct rtc_time time; }; The enabled flag is used to enable or disable the alarm interrupt, or to read its current status; when using these calls, RTC_AIE_ON and RTC_AIE_OFF are not used. The pending flag is used by RTC_WKALM_RD to report a pending interrupt (so it's mostly useless on Linux, except when talking to the RTC managed by EFI firmware). The time field is as used with RTC_ALM_READ and RTC_ALM_SET except that the tm_mday, tm_mon, and tm_year fields are also valid. A pointer to this structure should be passed as the third ioctl's argument. Implementation notes: All ioctls in this patch have a pointer to a structure rtc_wkalrm as their third argument. That is the reason why corresponding definition is added in linux-user/syscall_types.h. Since all elements of this structure are either of type 'unsigned char' or 'struct rtc_time' (that was covered in one of previous patches), the rest of the implementation is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-5-git-send-email-Filip.Bozuta@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ linux-user/syscall_types.h | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 9e91eaae7705..e4c1fbf52b1b 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -85,6 +85,8 @@ IOCTL(RTC_IRQP_SET, IOC_W, TYPE_ULONG) IOCTL(RTC_EPOCH_READ, IOC_R, MK_PTR(TYPE_ULONG)) IOCTL(RTC_EPOCH_SET, IOC_W, TYPE_ULONG) + IOCTL(RTC_WKALM_RD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) + IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index fcbb2ee9a387..c33432a374e5 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -780,6 +780,8 @@ struct target_pollfd { #define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong) #define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong) #define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong) +#define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm) +#define TARGET_RTC_WKALM_SET TARGET_IOW('p', 0x0f, struct rtc_wkalrm) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index bddc89a6641b..3efa9536ccfa 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -266,6 +266,11 @@ STRUCT(rtc_time, TYPE_INT, /* tm_yday */ TYPE_INT) /* tm_isdst */ +STRUCT(rtc_wkalrm, + TYPE_CHAR, /* enabled */ + TYPE_CHAR, /* pending */ + MK_STRUCT(STRUCT_rtc_time)) /* time */ + STRUCT(blkpg_ioctl_arg, TYPE_INT, /* op */ TYPE_INT, /* flags */ From patchwork Thu Jan 23 08:22:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347035 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53977921 for ; Thu, 23 Jan 2020 08:28:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E52DD24125 for ; Thu, 23 Jan 2020 08:28:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E52DD24125 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXr8-0001Nk-Dq for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:28:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56114) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlW-0001Od-5B for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlU-0003BM-R2 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:02 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:37767) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iuXlU-0003AO-Hf for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:23:00 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MWAf4-1j630V3rFS-00XYnL; Thu, 23 Jan 2020 09:22:42 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 16/17] linux-user: Add support for getting/setting RTC PLL correction using ioctls Date: Thu, 23 Jan 2020 09:22:26 +0100 Message-Id: <20200123082227.2037994-17-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:oMcSg9GRD3bTnJW2NH3roPN7XwG5h4iheUjy3D4zwUcPXX5pAjQ e4NFlR1jNdqVLW19GVz1SRl3WiTrvsJ7NmqTuws33Qc74/OXQo8J1jP1z+E1Yuw6dPm62Y5 wcKafRlxczFSRs8ZfyjsUq/U7zW0RTOfyn9Ci8+N2KjqAUJ33dyhCBKKmHc9XleWuTAZg9E NS+l3XioavmegN7REtBFw== X-UI-Out-Filterresults: notjunk:1;V03:K0:g4flJtB8bK4=:Vj7AaXocgAXRQrMgXxVA6O Rli4biuoLjnyh/EQyrpAll9vg0AuHzKSKAmAy8RIqoKR9SrBfWk3LxXG4y7oFrtiDqn5py8Bf lQcyXqlaX9MBEMV28xLmi3TPDftku7QeygSkBQTOR4p48cSY5EiMW3QSe09dRPYvCKHDBbEte Dhglwf/wrI5IM8y4+hhFbRUcJTevPuZ+Iva+Kf0kZiqx60saTcGNdUaGMDqGkr1FTW+nicWgt yhIhnCMQkdvlXYk51Ot514GFWcI0Q1bMmarcSFefM1q4CaYA2NeJ9GVO8VxIXRS4VBYWac5kT 1WsZNL9QD8EK+aWy3l2T36gqFrZ4PYGMSYZvUnfS3p0HE7QYBA7sQRzxAdgrnq02KVH5YJwrW eZDBUFK7UkYL39pJyGO0Nv0lqsRDwgDGFOPTFLQJSw3iZimTWHuAHrBQ9Ex9uN2Rmsg//pG0k P7HFynWWgSMDjTQUXx+1R6CDXnz93ZDLxuIuyvhnPirL7sEfJjJ1feegxW+jU3j/Yp4+o6Iv+ DSrHUNESsek0BJNTgQHpwke8qJvx0tM/WSHZuDuGMx7SdP4JX1sPhn17xmnhktGTjTJnCuX2U hsmRml2LpvQRHCK/nOmK4fBUBD7He1M1wehT72OPOwpBQRj1FbOgB0B45FlrKjUAftyYY2i+W ajZndSELg+qV0PxzBQX6VcLllu0oCPB8u7xE2ovhgOHmUEXMB/Vx77bU2onVOZkzH5YR2mseb fRgJG37peePMSrbeKLYpaZf20jLAlGcC9c0GtoxOBUijqKEejhqPAYmOG0OeStAETILoTRlon a8QpeLN8thliN32z7dLn7BGNBEz+j2QXYAAJbcW0zHWOf8JYIFnxfO8jtiuJQELo6HAE0mL X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.130 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_PLL_GET - Getting PLL correction Read the PLL correction for RTCs that support PLL. The PLL correction is returned in the following structure: struct rtc_pll_info { int pll_ctrl; /* placeholder for fancier control */ int pll_value; /* get/set correction value */ int pll_max; /* max +ve (faster) adjustment value */ int pll_min; /* max -ve (slower) adjustment value */ int pll_posmult; /* factor for +ve correction */ int pll_negmult; /* factor for -ve correction */ long pll_clock; /* base PLL frequency */ }; A pointer to this structure should be passed as the third ioctl's argument. RTC_PLL_SET - Setting PLL correction Sets the PLL correction for RTCs that support PLL. The PLL correction that is set is specified by the rtc_pll_info structure pointed to by the third ioctl's' argument. Implementation notes: All ioctls in this patch have a pointer to a structure rtc_pll_info as their third argument. All elements of this structure are of type 'int', except the last one that is of type 'long'. That is the reason why a separate target structure (target_rtc_pll_info) is defined in linux-user/syscall_defs. The rest of the implementation is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-6-git-send-email-Filip.Bozuta@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 14 ++++++++++++++ linux-user/syscall_types.h | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index e4c1fbf52b1b..789764d11314 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -87,6 +87,8 @@ IOCTL(RTC_EPOCH_SET, IOC_W, TYPE_ULONG) IOCTL(RTC_WKALM_RD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) + IOCTL(RTC_PLL_GET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) + IOCTL(RTC_PLL_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index c33432a374e5..9f7aad49c683 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -763,6 +763,16 @@ struct target_pollfd { #define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */ #define TARGET_KDSIGACCEPT 0x4B4E +struct target_rtc_pll_info { + int pll_ctrl; + int pll_value; + int pll_max; + int pll_min; + int pll_posmult; + int pll_negmult; + abi_long pll_clock; +}; + /* real time clock ioctls */ #define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01) #define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02) @@ -782,6 +792,10 @@ struct target_pollfd { #define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong) #define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm) #define TARGET_RTC_WKALM_SET TARGET_IOW('p', 0x0f, struct rtc_wkalrm) +#define TARGET_RTC_PLL_GET TARGET_IOR('p', 0x11, \ + struct target_rtc_pll_info) +#define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \ + struct target_rtc_pll_info) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 3efa9536ccfa..5ba4155047ba 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -271,6 +271,15 @@ STRUCT(rtc_wkalrm, TYPE_CHAR, /* pending */ MK_STRUCT(STRUCT_rtc_time)) /* time */ +STRUCT(rtc_pll_info, + TYPE_INT, /* pll_ctrl */ + TYPE_INT, /* pll_value */ + TYPE_INT, /* pll_max */ + TYPE_INT, /* pll_min */ + TYPE_INT, /* pll_posmult */ + TYPE_INT, /* pll_negmult */ + TYPE_LONG) /* pll_clock */ + STRUCT(blkpg_ioctl_arg, TYPE_INT, /* op */ TYPE_INT, /* flags */ From patchwork Thu Jan 23 08:22:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 11347047 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF25B921 for ; Thu, 23 Jan 2020 08:32:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8FAB924673 for ; Thu, 23 Jan 2020 08:32:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FAB924673 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=vivier.eu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:53166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXum-0005ym-SL for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Jan 2020 03:32:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56059) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuXlR-0001GB-8b for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuXlQ-00035N-5j for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:57 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:58937) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuXlP-00034v-T5 for qemu-devel@nongnu.org; Thu, 23 Jan 2020 03:22:56 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N6KpF-1jeYg71cUb-016clM; Thu, 23 Jan 2020 09:22:42 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 17/17] linux-user: Add support for read/clear RTC voltage low detector using ioctls Date: Thu, 23 Jan 2020 09:22:27 +0100 Message-Id: <20200123082227.2037994-18-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200123082227.2037994-1-laurent@vivier.eu> References: <20200123082227.2037994-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Gr9Cw03uQnZoGOJDZCLFvBQUvTYF5geC4VHLGRbkZhIZgbaW8Zw CxlhlXrBt3r5W+Eah86w3RiuRwd/0bof04IpjuYNNrM3ulRXqOh+Xtjf3bXn9ibZVENK0mo PDyMhIC+7b5RUgwyPiYifVWEVeHjJXFK6CswFM3bSI8j6ZtdlRt8r0IgqjPhECqOMSOMtwl qzf33rdT9C1TEVpHzCGCQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:jJWSIJ0pyJA=:duqCn3GQrdsWSs9elTiW+/ qFroFsQk+TKFp1+BevxB3qDj8n32TDvGNxqz9Zs/x4GoO+sH38x7R1VuxtIvGmfp/z0qCZXXd MKT7sfnm3Oxy4YpNXkCm9rCmGgNZsCGwDtINgWcABmoPT12gEqjypcKjCfh7ONMeeC4YSEFS2 8Q5dGYlW7ibek4jAdipAtV6JnIwcVwIcanIN/9aOyOokkM1lrdzu45f27fnp2B/0+zDLH7UuK 0LrqM5Z3t/4fx1OwuV+5V0lh7RMEbbhRdu5KHQysGIyIJ2mBWR8xobaOxl397+qbgA1E6u8Xn 4dVXkMkGqFlDghsHerRDcywuh5OsSjomojQo8GcUx0Jdy/h4xg/JqMrITf2BDIzbEfMZI7x6g /UBNlh/ciWX2jAQPXDrwuhBVdOE6aOmFgewLWFjaolXP0oqfQ5m7zqdoe8+s1qJfukXFvEvg6 kYYZJLsSWWELKssvtoe8VvHRAfKTZ+yxBZVAgoy08TJDI5hh7sRsJ7kCJ1yggInec6laQojjB Ko4dEhk7wPgiTwUwE+vLIVHmsjAVeh7NLQGRVbhY4Cv6K/wq2DZ5tNPclGuJmx1//3jGb49Rq m1Z+3u4ZZikSDAEfz1btJEOgezDpVo/lzN/H7A8BPHtS9GEPgZ7Tm+HuMmwkCp/+ByWb0NfTh 9n94+pxWKD8ScKkoUKwhl6ZGon8thO5lCVql4iyh0jzP40n6DDNNY06dBuSoLppd43O1ffEFl TshczqSykLjlQgiBEZd2BKisLxEJJDvuVQijCgqZi0gkGNQZ6pZ9Tx0Z+sKU++LaCqnmDQEe2 ogE+c7mbSflbJepULseNw6aLxoQ55H8YnfFhvDRxlvEo64BI3Q= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.187 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , Filip Bozuta Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_VL_READ - Read voltage low detection information Read the voltage low for RTCs that support voltage low. The third ioctl's' argument points to an int in which the voltage low is returned. RTC_VL_CLR - Clear voltage low information Clear the information about voltage low for RTCs that support voltage low. The third ioctl(2) argument is ignored. Implementation notes: Since one ioctl has a pointer to 'int' as its third agrument, and another ioctl has NULL as its third argument, their implementation was straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-7-git-send-email-Filip.Bozuta@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 789764d11314..73dcc761e642 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -89,6 +89,8 @@ IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) IOCTL(RTC_PLL_GET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) IOCTL(RTC_PLL_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) + IOCTL(RTC_VL_READ, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(RTC_VL_CLR, 0, TYPE_NULL) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 9f7aad49c683..9b61ae8547dd 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -796,6 +796,8 @@ struct target_rtc_pll_info { struct target_rtc_pll_info) #define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \ struct target_rtc_pll_info) +#define TARGET_RTC_VL_READ TARGET_IOR('p', 0x13, int) +#define TARGET_RTC_VL_CLR TARGET_IO('p', 0x14) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA)