From patchwork Tue Jun 16 10:20:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1310219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=RUfGnWzj; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49mPNY2wxJz9sSc for ; Tue, 16 Jun 2020 20:20:45 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B95303C2D17 for ; Tue, 16 Jun 2020 12:20:42 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 312783C2D06 for ; Tue, 16 Jun 2020 12:20:34 +0200 (CEST) Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 34F421BCD7BD for ; Tue, 16 Jun 2020 12:20:33 +0200 (CEST) Received: by mail-pj1-x1043.google.com with SMTP id a45so1046867pje.1 for ; Tue, 16 Jun 2020 03:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LqWPuZuYXoYkRhOsIMXrTm0u8fyyDqJ6HTW9Vjml2OM=; b=RUfGnWzjZ+T8/JU/pmzh5VidFyT8WijLKlen84MpiH/5UyqXq1+DeJqPxIpCMaYILq IN8Rn7nLNM6ZXxBqEEnsCp2XMawgOoH079jPOKEZdY65fyFa5qFcs0v00VEMW1R9X6f6 1WcG4ckWVbDP7rs+SYL0dV7jW//zpP3X+JrgGWxkaEVEK6/K6RFCy+wY7PXqkcgolQQC FNqovm+TWTGTSPIPDcY6eA//ESHoClBFe3ysVzFXj4ck2GysUhrUanTIwZgFqGeIaNkh mqfycrGrNpRpfuRMTu6X8jQhIChBWbRvWZHZ4YcfQPTQ1D4LWP0+0vikG38TJzyETobL N8tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LqWPuZuYXoYkRhOsIMXrTm0u8fyyDqJ6HTW9Vjml2OM=; b=hjT5huXwEhq2X/rwf774XMkvPokVU7ubh8CdrNNTtxKuGXBhsSzAi0WMfzaRSs1h99 7NtYsJKvoK6/B7IsdIReUqWtA2PB97dGTtORyT1t6NFyQnfb5J4/oEzcW1mVK/gpKBT0 C/Uf35rN8BKVWptj+XnwMQFGGTZo7shOuekkkz2hC8lGP4yr2SdWh/EPWKwHaVWgRU5p F1cSs2RUugRTCTJIunQp82c9ThGd0Ae9V9I5Dxnbpc0odeX088r/nd7rQUqrjG3wZQwA Y8K8iFlzMiRJpEtFiIKtj2J0nxVafy5rjJkQjBrYZL5AVCvB5c/gjW0BIpBKCwf5gSh2 Im9g== X-Gm-Message-State: AOAM533dl1X0lFMw5KgjIz3iKe5zkuqUJOQtgMD93sY65lNyB8txRKiC nFd/P+TjRBe7AhSOG5KZ5pJ425W56Lk= X-Google-Smtp-Source: ABdhPJx1clWag9xyFo6zSyQGA7q3fssOBS74icLfGDYw+Xa31MOZn4Ix59Deg2PfnSxmLc5FgCQbtg== X-Received: by 2002:a17:90a:32d1:: with SMTP id l75mr2188343pjb.85.1592302831319; Tue, 16 Jun 2020 03:20:31 -0700 (PDT) Received: from localhost ([122.172.119.132]) by smtp.gmail.com with ESMTPSA id i125sm13839696pgd.21.2020.06.16.03.20.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2020 03:20:30 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 16 Jun 2020 15:50:19 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH V2 1/6] include: Add declaration of struct semid64_ds X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot , arnd@arndb.de, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This adds declaration of struct semid64_ds, which will be used by following patches. Signed-off-by: Viresh Kumar --- configure.ac | 1 + include/lapi/sembuf.h | 234 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 235 insertions(+) create mode 100644 include/lapi/sembuf.h diff --git a/configure.ac b/configure.ac index eaf33dd60350..c513fdf440c2 100644 --- a/configure.ac +++ b/configure.ac @@ -151,6 +151,7 @@ AC_CHECK_TYPES([struct fs_quota_statv],,,[#include ]) AC_CHECK_TYPES([struct if_nextdqblk],,,[#include ]) AC_CHECK_TYPES([struct iovec],,,[#include ]) AC_CHECK_TYPES([struct ipc64_perm],,,[#include ]) +AC_CHECK_TYPES([struct semid64_ds],,,[#include ]) AC_CHECK_TYPES([struct mmsghdr],,,[ #define _GNU_SOURCE diff --git a/include/lapi/sembuf.h b/include/lapi/sembuf.h new file mode 100644 index 000000000000..00263abca995 --- /dev/null +++ b/include/lapi/sembuf.h @@ -0,0 +1,234 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Linaro Limited. All rights reserved. + * Author: Viresh Kumar + */ + +#ifndef IPC_SEMBUF_H +#define IPC_SEMBUF_H + +#include +#include +#include "tst_timer.h" +#include "ipcbuf.h" + +#ifndef HAVE_SEMID64_DS + +#if defined(__mips__) +#define HAVE_SEMID64_DS +/* + * The semid64_ds structure for the MIPS architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for 2 miscellaneous 64-bit values on mips64, + * but used for the upper 32 bit of the time values on mips32. + */ +#if defined(__arch64__) +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ + long sem_otime; /* last semop time */ + long sem_ctime; /* last change time */ + unsigned long sem_nsems; /* no. of semaphores in array */ + unsigned long __unused1; + unsigned long __unused2; +}; +#else +#define HAVE_SEMID64_DS_TIME_HIGH +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ + unsigned long sem_otime; /* last semop time */ + unsigned long sem_ctime; /* last change time */ + unsigned long sem_nsems; /* no. of semaphores in array */ + unsigned long sem_otime_high; + unsigned long sem_ctime_high; +}; +#endif +#endif /* __mips__ */ + +#if defined(__hppa__) +#define HAVE_SEMID64_DS +/* + * The semid64_ds structure for parisc architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ +#if __BITS_PER_LONG == 64 + long sem_otime; /* last semop time */ + long sem_ctime; /* last change time */ +#else +#define HAVE_SEMID64_DS_TIME_HIGH + unsigned long sem_otime_high; + unsigned long sem_otime; /* last semop time */ + unsigned long sem_ctime_high; + unsigned long sem_ctime; /* last change time */ +#endif + unsigned long sem_nsems; /* no. of semaphores in array */ + unsigned long __unused1; + unsigned long __unused2; +}; +#endif /* __hppa__ */ + +#if defined(__powerpc__) || defined(__powerpc64__) +#define HAVE_SEMID64_DS +/* + * The semid64_ds structure for PPC architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32/64-bit values + */ + +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ +#ifndef __powerpc64__ +#define HAVE_SEMID64_DS_TIME_HIGH + unsigned long sem_otime_high; + unsigned long sem_otime; /* last semop time */ + unsigned long sem_ctime_high; + unsigned long sem_ctime; /* last change time */ +#else + long sem_otime; /* last semop time */ + long sem_ctime; /* last change time */ +#endif + unsigned long sem_nsems; /* no. of semaphores in array */ + unsigned long __unused3; + unsigned long __unused4; +}; +#endif /* defined(__powerpc__) || defined(__powerpc64__) */ + +#if defined(__sparc__) +#define HAVE_SEMID64_DS +/* + * The semid64_ds structure for sparc architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ +#if defined(__arch64__) + long sem_otime; /* last semop time */ + long sem_ctime; /* last change time */ +#else +#define HAVE_SEMID64_DS_TIME_HIGH + unsigned long sem_otime_high; + unsigned long sem_otime; /* last semop time */ + unsigned long sem_ctime_high; + unsigned long sem_ctime; /* last change time */ +#endif + unsigned long sem_nsems; /* no. of semaphores in array */ + unsigned long __unused1; + unsigned long __unused2; +}; +#endif /* __sparc__ */ + +#if defined(__x86_64__) +#define HAVE_SEMID64_DS +/* + * The semid64_ds structure for x86 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + * + * x86_64 and x32 incorrectly added padding here, so the structures + * are still incompatible with the padding on x86. + */ +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ +#ifdef __i386__ +#define HAVE_SEMID64_DS_TIME_HIGH + unsigned long sem_otime; /* last semop time */ + unsigned long sem_otime_high; + unsigned long sem_ctime; /* last change time */ + unsigned long sem_ctime_high; +#else + __kernel_long_t sem_otime; /* last semop time */ + __kernel_ulong_t __unused1; + __kernel_long_t sem_ctime; /* last change time */ + __kernel_ulong_t __unused2; +#endif + __kernel_ulong_t sem_nsems; /* no. of semaphores in array */ + __kernel_ulong_t __unused3; + __kernel_ulong_t __unused4; +}; +#endif /* defined(__x86_64__) */ + +#if defined(__xtensa__) +#define HAVE_SEMID64_DS +#define HAVE_SEMID64_DS_TIME_HIGH + +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ +#ifdef __XTENSA_EL__ + unsigned long sem_otime; /* last semop time */ + unsigned long sem_otime_high; + unsigned long sem_ctime; /* last change time */ + unsigned long sem_ctime_high; +#else + unsigned long sem_otime_high; + unsigned long sem_otime; /* last semop time */ + unsigned long sem_ctime_high; + unsigned long sem_ctime; /* last change time */ +#endif + unsigned long sem_nsems; /* no. of semaphores in array */ + unsigned long __unused3; + unsigned long __unused4; +}; + +#endif /* __xtensa__ */ + +#ifndef HAVE_SEMID64_DS +/* + * The semid64_ds structure for most architectures (though it came + * from x86_32 originally). Note extra padding because this structure + * is passed back and forth between kernel and user space. + * + * semid64_ds was originally meant to be architecture specific, but + * everyone just ended up making identical copies without specific + * optimizations, so we may just as well all use the same one. + * + * 64 bit architectures use a 64-bit long time field here, while + * 32 bit architectures have a pair of unsigned long values. + * + * On big-endian systems, the padding is in the wrong place for + * historic reasons, so user space has to reconstruct a time_t + * value using + * + * user_semid_ds.sem_otime = kernel_semid64_ds.sem_otime + + * ((long long)kernel_semid64_ds.sem_otime_high << 32) + * + * Pad space is left for 2 miscellaneous 32-bit values + */ +struct semid64_ds { + struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ +#if __BITS_PER_LONG == 64 + long sem_otime; /* last semop time */ + long sem_ctime; /* last change time */ +#else +#define HAVE_SEMID64_DS_TIME_HIGH + unsigned long sem_otime; /* last semop time */ + unsigned long sem_otime_high; + unsigned long sem_ctime; /* last change time */ + unsigned long sem_ctime_high; +#endif + unsigned long sem_nsems; /* no. of semaphores in array */ + unsigned long __unused3; + unsigned long __unused4; +}; +#endif /* semid64_ds */ + +#endif /* HAVE_SEMID64_DS */ + +#endif /* IPC_SEMBUF_H */ From patchwork Tue Jun 16 10:20:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1310220 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=S3iHWCUy; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49mPNl0Zrwz9sT2 for ; Tue, 16 Jun 2020 20:20:55 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 85A223C2D11 for ; Tue, 16 Jun 2020 12:20:52 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 6C8B13C2D0C for ; Tue, 16 Jun 2020 12:20:36 +0200 (CEST) Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id A1E3A629819 for ; Tue, 16 Jun 2020 12:20:35 +0200 (CEST) Received: by mail-pl1-x644.google.com with SMTP id g12so8179461pll.10 for ; Tue, 16 Jun 2020 03:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RgxRB4WNbjPqWnUp4sX/XQVRpZsseiDDkCAbdUxYvJU=; b=S3iHWCUyGksSbicV7INn32lOC+NhIdoAi0sSbBqSOjmNRDD6YWirnK6Ra1/yUvmckY YBYRN66STbriIfA5+7GZTE5gVfCRpXyeBkyLCoP1euFkC4xq84ZWM0JT52Orpw5MszuJ C3/TLJNFmydsN4G4gSZNJ9vwygM9hvjwv8pfxs0zDGk9hdoAHfdzxKazQ7RTtSIJZusu +t6hS5kHNN+y7AIgqivWzA15nhvyr3ahIoYZhppUl4NOONy0WF+ZqU70AZvTSsRuW/fa GfEjG2Id97FoE6xGoPFuITOIL9KNvhQ8dkZy7oX3xUwCvvLf3HZmo0qqeRaPTqzZbV+1 mq8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RgxRB4WNbjPqWnUp4sX/XQVRpZsseiDDkCAbdUxYvJU=; b=sfP+sF0fPpRpEP6mtceD/X5I/kkCay6fQ6a8kLeqDHw/u9IlFR/2/grDtvuOTncFXu m63VxVt3ThhiDXEuhgnY2YcRs2YDS3FrXlcEGHrCgNiC2TRrjckavXyG5jy3iRuhmWZM TlJO3dSZ9tRXpOcYC2Qv/Vd6JLY5ByVuh7QWBZdiOZyTvAfU+0646omhRRwopWCSwHmN +XGz9nbFq7H8Saduwr0vL2f8keZaulK8LMfQOI7cqDNVja/pCANEijC7PC7qe1YFphcf JVoaJ/KNEKvD3Hp88tP1dEtJUGKJtrv9vacXIeo0nh3piIyLylSutA81ddruqXkdBg6N fEWw== X-Gm-Message-State: AOAM53318+DKneaurbjCZGP6zmj9mfgue0/212mIgoRYo1/9YhUgOlV2 Eg0P89cmSIP979UFcR5FDDqz2MEMQMI= X-Google-Smtp-Source: ABdhPJxLNoCmHL+wmKr1ytOjgiITuZdLa5hDAENwsVHSp5PFwmS9aaV9ohj/h+0QUVkJAxwaHlQd3Q== X-Received: by 2002:a17:90b:3809:: with SMTP id mq9mr2307874pjb.156.1592302833894; Tue, 16 Jun 2020 03:20:33 -0700 (PDT) Received: from localhost ([122.172.119.132]) by smtp.gmail.com with ESMTPSA id h6sm16725630pfq.214.2020.06.16.03.20.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2020 03:20:33 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 16 Jun 2020 15:50:20 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH V2 2/6] syscalls: semctl: Add new test to verify the _time_high fields X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot , arnd@arndb.de, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The _time_high fields must be reset by the kernel, add a test to verify that. Suggested-by: Arnd Bergmann Signed-off-by: Viresh Kumar --- runtest/syscalls | 1 + runtest/syscalls-ipc | 1 + .../kernel/syscalls/ipc/semctl/.gitignore | 1 + testcases/kernel/syscalls/ipc/semctl/Makefile | 5 +- .../kernel/syscalls/ipc/semctl/semctl08.c | 52 +++++++++++++++++++ 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 testcases/kernel/syscalls/ipc/semctl/semctl08.c diff --git a/runtest/syscalls b/runtest/syscalls index bee03e93f765..eedd727fb617 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1157,6 +1157,7 @@ semctl04 semctl04 semctl05 semctl05 semctl06 semctl06 semctl07 semctl07 +semctl08 semctl08 semget01 semget01 semget02 semget02 diff --git a/runtest/syscalls-ipc b/runtest/syscalls-ipc index 54d8622d4223..f912cb067f74 100644 --- a/runtest/syscalls-ipc +++ b/runtest/syscalls-ipc @@ -33,6 +33,7 @@ semctl04 semctl04 semctl05 semctl05 semctl06 semctl06 semctl07 semctl07 +semctl08 semctl08 semget01 semget01 semget02 semget02 diff --git a/testcases/kernel/syscalls/ipc/semctl/.gitignore b/testcases/kernel/syscalls/ipc/semctl/.gitignore index b6899acf5da6..6189a04cc3c6 100644 --- a/testcases/kernel/syscalls/ipc/semctl/.gitignore +++ b/testcases/kernel/syscalls/ipc/semctl/.gitignore @@ -5,3 +5,4 @@ /semctl05 /semctl06 /semctl07 +/semctl08 diff --git a/testcases/kernel/syscalls/ipc/semctl/Makefile b/testcases/kernel/syscalls/ipc/semctl/Makefile index f62cd1f481d9..99971a7dbb32 100644 --- a/testcases/kernel/syscalls/ipc/semctl/Makefile +++ b/testcases/kernel/syscalls/ipc/semctl/Makefile @@ -3,10 +3,11 @@ top_srcdir ?= ../../../../.. -LTPLIBS = ltpipc +LTPLIBS = ltpipc ltpnewipc include $(top_srcdir)/include/mk/testcases.mk -LDLIBS += -lltpipc +semctl01 semctl02 semctl03 semctl04 semctl05 semctl06 semctl07: LDLIBS += -lltpipc +semctl08: LDLIBS += -lltpnewipc include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl08.c b/testcases/kernel/syscalls/ipc/semctl/semctl08.c new file mode 100644 index 000000000000..40c2e1741d3a --- /dev/null +++ b/testcases/kernel/syscalls/ipc/semctl/semctl08.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Cross verify the _high fields being set to 0 by the kernel. + */ +#include "lapi/sembuf.h" +#include "lapi/semun.h" +#include "tst_test.h" +#include "libnewipc.h" + +#ifdef HAVE_SEMID64_DS_TIME_HIGH + +static void run(void) +{ + struct semid64_ds buf_ds = { + .sem_otime_high = 0x0A0A, + .sem_ctime_high = 0x0A0A, + }; + int semid; + union semun arg; + key_t key; + + /* get an IPC resource key */ + key = GETIPCKEY(); + + semid = semget(key, 1, SEM_RA | IPC_CREAT); + if (semid == -1) + tst_brk(TBROK | TERRNO, "couldn't create semaphore"); + + arg.buf = (struct semid_ds *)&buf_ds; + TEST(semctl(semid, 0, IPC_STAT, arg)); + if (TST_RET == -1) + tst_brk(TFAIL | TTERRNO, "semctl() failed"); + + if (buf_ds.sem_otime_high || buf_ds.sem_ctime_high) + tst_res(TFAIL, "time_high fields aren't cleared by the kernel"); + else + tst_res(TPASS, "time_high fields cleared by the kernel"); + + if (semctl(semid, 0, IPC_RMID, arg) == -1) + tst_res(TINFO, "WARNING: semaphore deletion failed."); +} + +static struct tst_test test = { + .test_all = run, + .needs_tmpdir = 1, +}; +#else +TST_TEST_TCONF("test requires struct semid64_ds to have the time_high fields"); +#endif From patchwork Tue Jun 16 10:20:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1310221 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=sqSo0gT9; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49mPNz06dRz9sT2 for ; Tue, 16 Jun 2020 20:21:06 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 506AA3C2CF3 for ; Tue, 16 Jun 2020 12:21:04 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id ECBEB3C2D0D for ; Tue, 16 Jun 2020 12:20:39 +0200 (CEST) Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 0E1EA629818 for ; Tue, 16 Jun 2020 12:20:39 +0200 (CEST) Received: by mail-pf1-x441.google.com with SMTP id j1so9284895pfe.4 for ; Tue, 16 Jun 2020 03:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tzzHWamb13xW7967jra4N5YtKDcjb+WDgL4K7uvKMi4=; b=sqSo0gT9uTiOH43Vq2EHq+z0LkwkxmJQMXRQ1IV0DqlRC9/8j0iTrgwvAsg2lKeai6 /s+12gvh7dHELENdAqyIBrA9TXuElpirYly++AywNbpjHjOGK6ENZnw8AorMbTyCYr00 hR0RNrTeTn4REqqKEqltBRVOVIcLOsA3b9RuDPBqOqxbIYoKZl0yWwyBw53aX9h6x+Xo My5ff2vDQMqBPcSCbE+Sam/HIGYppllwWkpiNtCB2QpYpFt09WmtkNG2jLsHT3MCKYee 91R6K/iskgsfBRY3zEEMD/+47z/3aLomSddKbXksgA8UvIPBsQ/ZXSryCVRp/o1wYYSb 27jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tzzHWamb13xW7967jra4N5YtKDcjb+WDgL4K7uvKMi4=; b=p5n1PMIq7LoB0SBgcv4cntgg+pA0z+tw3sz/a42epGgPj+O11Y9frFoZvArbpPRL/s ppiqD+FmUAeh8z0aQYqoLoT+mVCNNqB9zPvN2XlcQoZN4TI2w9wSEvwkJDgtJf6L9h4k hRmidr/wZJVBzLcgf+Gb0OOHOVyG94UFvhih+iXtPlLIR5tnWrVxOvgUwjx3PUAHD9do +VVXN/jBmcRS7YnaP9d++sADahYn97TdBP69ZaiWaojDNLA3vdGzgo5eByHEqWDixEIf jD2o9EOTT6ik3eMEuHWIgmwwItFQWMddohA85o1wCT+Ne4/iz5NfEBcjmuRSsVQ88cCK DeKQ== X-Gm-Message-State: AOAM533+2jym0j9bw9uRjhgc29s3QnqsawUTJjDw5mDyIV2sOr3/Gygy 37K2WZiapKibi7Kd8zHtOdVkqWT516k= X-Google-Smtp-Source: ABdhPJzuNJ0xlUafvuSv7m0d23aamquH7ruJJsm5UWIT/FavzFyKwZDHcGWSB6ybpJ/BcfNvaEHiBw== X-Received: by 2002:a63:7c56:: with SMTP id l22mr1493844pgn.127.1592302836993; Tue, 16 Jun 2020 03:20:36 -0700 (PDT) Received: from localhost ([122.172.119.132]) by smtp.gmail.com with ESMTPSA id m1sm2055663pjr.56.2020.06.16.03.20.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2020 03:20:36 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 16 Jun 2020 15:50:21 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH V2 3/6] include: Add declaration of struct shmid64_ds X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot , arnd@arndb.de, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This adds declaration of struct shmid64_ds, which will be used by following patches. Signed-off-by: Viresh Kumar --- configure.ac | 1 + include/lapi/shmbuf.h | 273 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 274 insertions(+) create mode 100644 include/lapi/shmbuf.h diff --git a/configure.ac b/configure.ac index c513fdf440c2..f1ee98b23cbe 100644 --- a/configure.ac +++ b/configure.ac @@ -152,6 +152,7 @@ AC_CHECK_TYPES([struct if_nextdqblk],,,[#include ]) AC_CHECK_TYPES([struct iovec],,,[#include ]) AC_CHECK_TYPES([struct ipc64_perm],,,[#include ]) AC_CHECK_TYPES([struct semid64_ds],,,[#include ]) +AC_CHECK_TYPES([struct shmid64_ds],,,[#include ]) AC_CHECK_TYPES([struct mmsghdr],,,[ #define _GNU_SOURCE diff --git a/include/lapi/shmbuf.h b/include/lapi/shmbuf.h new file mode 100644 index 000000000000..f8c1294c60d6 --- /dev/null +++ b/include/lapi/shmbuf.h @@ -0,0 +1,273 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Linaro Limited. All rights reserved. + * Author: Viresh Kumar + */ + +#ifndef IPC_SHMBUF_H +#define IPC_SHMBUF_H + +#include +#include +#include "tst_timer.h" +#include "ipcbuf.h" + +#ifndef HAVE_SHMID64_DS + +#if defined(__mips__) +#define HAVE_SHMID64_DS +/* + * The shmid64_ds structure for the MIPS architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * As MIPS was lacking proper padding after shm_?time, we use 48 bits + * of the padding at the end to store a few additional bits of the time. + * libc implementations need to take care to convert this into a proper + * data structure when moving to 64-bit time_t. + */ + +#if defined(__arch64__) +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ + long shm_atime; /* last attach time */ + long shm_dtime; /* last detach time */ + long shm_ctime; /* last change time */ + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused1; + unsigned long __unused2; +}; +#else +#define HAVE_SHMID64_DS_TIME_HIGH +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ + unsigned long shm_atime; /* last attach time */ + unsigned long shm_dtime; /* last detach time */ + unsigned long shm_ctime; /* last change time */ + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned short shm_atime_high; + unsigned short shm_dtime_high; + unsigned short shm_ctime_high; + unsigned short __unused1; +}; +#endif + +#endif /* __mips__ */ + +#if defined(__hppa__) +#define HAVE_SHMID64_DS +/* + * The shmid64_ds structure for parisc architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ +#if __BITS_PER_LONG == 64 + long shm_atime; /* last attach time */ + long shm_dtime; /* last detach time */ + long shm_ctime; /* last change time */ +#else +#define HAVE_SHMID64_DS_TIME_HIGH + unsigned long shm_atime_high; + unsigned long shm_atime; /* last attach time */ + unsigned long shm_dtime_high; + unsigned long shm_dtime; /* last detach time */ + unsigned long shm_ctime_high; + unsigned long shm_ctime; /* last change time */ + unsigned int __pad4; +#endif + __kernel_size_t shm_segsz; /* size of segment (bytes) */ + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused1; + unsigned long __unused2; +}; +#endif /* __hppa__ */ + +#if defined(__powerpc__) || defined(__powerpc64__) +#define HAVE_SHMID64_DS +/* + * The shmid64_ds structure for PPC architecture. + * + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ +#ifdef __powerpc64__ + long shm_atime; /* last attach time */ + long shm_dtime; /* last detach time */ + long shm_ctime; /* last change time */ +#else +#define HAVE_SHMID64_DS_TIME_HIGH + unsigned long shm_atime_high; + unsigned long shm_atime; /* last attach time */ + unsigned long shm_dtime_high; + unsigned long shm_dtime; /* last detach time */ + unsigned long shm_ctime_high; + unsigned long shm_ctime; /* last change time */ + unsigned long __unused4; +#endif + size_t shm_segsz; /* size of segment (bytes) */ + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused5; + unsigned long __unused6; +}; + +#endif /* defined(__powerpc__) || defined(__powerpc64__) */ + +#if defined(__sparc__) +#define HAVE_SHMID64_DS +/* + * The shmid64_ds structure for sparc architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ +#if defined(__arch64__) + long shm_atime; /* last attach time */ + long shm_dtime; /* last detach time */ + long shm_ctime; /* last change time */ +#else +#define HAVE_SHMID64_DS_TIME_HIGH + unsigned long shm_atime_high; + unsigned long shm_atime; /* last attach time */ + unsigned long shm_dtime_high; + unsigned long shm_dtime; /* last detach time */ + unsigned long shm_ctime_high; + unsigned long shm_ctime; /* last change time */ +#endif + size_t shm_segsz; /* size of segment (bytes) */ + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused1; + unsigned long __unused2; +}; + +#endif /* __sparc__ */ + +#if defined(__x86_64__) && defined(__ILP32__) +#define HAVE_SHMID64_DS +/* + * The shmid64_ds structure for x86 architecture with x32 ABI. + * + * On x86-32 and x86-64 we can just use the generic definition, but + * x32 uses the same binary layout as x86_64, which is differnet + * from other 32-bit architectures. + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ + __kernel_long_t shm_atime; /* last attach time */ + __kernel_long_t shm_dtime; /* last detach time */ + __kernel_long_t shm_ctime; /* last change time */ + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + __kernel_ulong_t shm_nattch; /* no. of current attaches */ + __kernel_ulong_t __unused4; + __kernel_ulong_t __unused5; +}; +#endif /* defined(__x86_64__) && defined(__ILP32__) */ + +#if defined(__xtensa__) +#define HAVE_SHMID64_DS +#define HAVE_SHMID64_DS_TIME_HIGH +/* + * The shmid64_ds structure for Xtensa architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space, but the padding is on the wrong + * side for big-endian xtensa, for historic reasons. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ + unsigned long shm_atime; /* last attach time */ + unsigned long shm_atime_high; + unsigned long shm_dtime; /* last detach time */ + unsigned long shm_dtime_high; + unsigned long shm_ctime; /* last change time */ + unsigned long shm_ctime_high; + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif /* __xtensa__ */ + +#ifndef HAVE_SHMID64_DS +/* + * The shmid64_ds structure for most architectures (though it came + * from x86_32 originally). Note extra padding because this structure + * is passed back and forth between kernel and user space. + * + * shmid64_ds was originally meant to be architecture specific, but + * everyone just ended up making identical copies without specific + * optimizations, so we may just as well all use the same one. + * + * 64 bit architectures use a 64-bit long time field here, while + * 32 bit architectures have a pair of unsigned long values. + * On big-endian systems, the lower half is in the wrong place. + * + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ +#if __BITS_PER_LONG == 64 + long shm_atime; /* last attach time */ + long shm_dtime; /* last detach time */ + long shm_ctime; /* last change time */ +#else +#define HAVE_SHMID64_DS_TIME_HIGH + unsigned long shm_atime; /* last attach time */ + unsigned long shm_atime_high; + unsigned long shm_dtime; /* last detach time */ + unsigned long shm_dtime_high; + unsigned long shm_ctime; /* last change time */ + unsigned long shm_ctime_high; +#endif + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + unsigned long shm_nattch; /* no. of current attaches */ + unsigned long __unused4; + unsigned long __unused5; +}; +#endif /* shmid64_ds */ + +#endif /* HAVE_SHMID64_DS */ + +#endif /* IPC_SHMBUF_H */ From patchwork Tue Jun 16 10:20:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1310222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=moDIfzOa; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49mPP71rpHz9sT2 for ; Tue, 16 Jun 2020 20:21:15 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B531C3C2CF9 for ; Tue, 16 Jun 2020 12:21:12 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 6587F3C2D13 for ; Tue, 16 Jun 2020 12:20:42 +0200 (CEST) Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 7BA88279906 for ; Tue, 16 Jun 2020 12:20:41 +0200 (CEST) Received: by mail-pl1-x643.google.com with SMTP id k6so3228721pll.9 for ; Tue, 16 Jun 2020 03:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TCgZGlw8LvJNPKWi3J4FTFnvZSBcvJzFsCHe17Stetg=; b=moDIfzOa/JjhAl5Vzn5A7I3yDNMu/wjRU1Yqhz2mynKvtRmIkhBDezTZcxD5ig53Ao zUKXs9uKgO3FZNJYIq/fUBUbE3OfW8VDUI7Xfj9j/Srxo9ouHo2sQTVnKXHAFmEWwo6m eBFtLBKlBd5SR6NvcQTJgC+VncDN+wNdwEvNt5BEIes2VBNlnLsuhwXSpISnsablmh0n BUfhwSc/yWkXiEyv+NrZQ0fv+uOLu0fgSaBxHQBhbtRkdEXWxGXmEKWsrScLjfhrG5fq iSEyvqYj93osOAghAX2reg9dKUhiS1Rq7AP60tY+etL1nKGHNJ6y3rOC3MfgP+Ce96lm uLXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TCgZGlw8LvJNPKWi3J4FTFnvZSBcvJzFsCHe17Stetg=; b=JZME0jpU5rfVh8uI3fCuuXCud8PfasT3ap4IvdN5+dt8XXnXVkXBIVp3M8mEYp82io YXUYgD4jhr/QtTjpHFey5fT7Cqwiv8yEkW9Zzgd23Y/OmiOldjgGBp/nuqs/pqoJP7la vajYAjhmJdEoCcWBqTsNC6oteqTkjSKa9DsZJaqhemY3VpBtog9BLf1jXdgC70YCeGIu qavALLX2it/2RkpF19EqIkppQYDaE2cutuKztIpzyV0j5L2gEh2NHdE9y5FIfTTdHDfB 4ZdiHR/RA9uOfRieJI3CXygR5FSK8TkUX3IBmVAD6IR5V/QmNneoLC2NBZI273ii7P4L kESw== X-Gm-Message-State: AOAM532gPVEPjvVirpDuc2Vze63Tf5OifqBs1SIyVNaghsFaTet0jLei RykuL9pe1cVgA64o2zjMoubQh5eXPqw= X-Google-Smtp-Source: ABdhPJz3e+Wg4RocNNoDLO6BO26in4pY38/KyOQ9aTX8lpIpBFVgBVcYcRxIYh5sFTZhbd83C7suRA== X-Received: by 2002:a17:902:599a:: with SMTP id p26mr1546626pli.322.1592302839649; Tue, 16 Jun 2020 03:20:39 -0700 (PDT) Received: from localhost ([122.172.119.132]) by smtp.gmail.com with ESMTPSA id y7sm17052421pfq.43.2020.06.16.03.20.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2020 03:20:39 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 16 Jun 2020 15:50:22 +0530 Message-Id: <7ed60e87527647505a71844b540a21db77ddae78.1592302358.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH V2 4/6] syscalls: shmctl: Add new test to verify the _time_high fields X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot , arnd@arndb.de, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The _time_high fields must be reset by the kernel, add a test to verify that. Suggested-by: Arnd Bergmann Signed-off-by: Viresh Kumar --- runtest/syscalls | 1 + runtest/syscalls-ipc | 1 + .../kernel/syscalls/ipc/shmctl/.gitignore | 1 + testcases/kernel/syscalls/ipc/shmctl/Makefile | 5 +- .../kernel/syscalls/ipc/shmctl/shmctl06.c | 51 +++++++++++++++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/syscalls/ipc/shmctl/shmctl06.c diff --git a/runtest/syscalls b/runtest/syscalls index eedd727fb617..f8b2277e0eda 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1355,6 +1355,7 @@ shmctl02 shmctl02 shmctl03 shmctl03 shmctl04 shmctl04 shmctl05 shmctl05 +shmctl06 shmctl06 shmdt01 shmdt01 shmdt02 shmdt02 diff --git a/runtest/syscalls-ipc b/runtest/syscalls-ipc index f912cb067f74..5ba3b1449a6c 100644 --- a/runtest/syscalls-ipc +++ b/runtest/syscalls-ipc @@ -55,6 +55,7 @@ shmctl02 shmctl02 shmctl03 shmctl03 shmctl04 shmctl04 shmctl05 shmctl05 +shmctl06 shmctl06 shmdt01 shmdt01 shmdt02 shmdt02 diff --git a/testcases/kernel/syscalls/ipc/shmctl/.gitignore b/testcases/kernel/syscalls/ipc/shmctl/.gitignore index d6777e3b8f1b..46b107344cf4 100644 --- a/testcases/kernel/syscalls/ipc/shmctl/.gitignore +++ b/testcases/kernel/syscalls/ipc/shmctl/.gitignore @@ -3,3 +3,4 @@ /shmctl03 /shmctl04 /shmctl05 +/shmctl06 diff --git a/testcases/kernel/syscalls/ipc/shmctl/Makefile b/testcases/kernel/syscalls/ipc/shmctl/Makefile index cfa5d6e76489..252c11058bc5 100644 --- a/testcases/kernel/syscalls/ipc/shmctl/Makefile +++ b/testcases/kernel/syscalls/ipc/shmctl/Makefile @@ -3,13 +3,16 @@ top_srcdir ?= ../../../../.. -LTPLIBS = ltpipc +LTPLIBS = ltpipc ltpnewipc shmctl05: CFLAGS += -pthread shmctl05: LDLIBS += -lrt include $(top_srcdir)/include/mk/testcases.mk +shmctl01 shmctl02 shmctl03 shmctl04 shmctl05: LDLIBS += -lltpipc +shmctl06: LDLIBS += -lltpnewipc + LDLIBS += -lltpipc include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl06.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl06.c new file mode 100644 index 000000000000..368759980b74 --- /dev/null +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl06.c @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Cross verify the _high fields being set to 0 by the kernel. + */ +#include +#include "lapi/shmbuf.h" +#include "libnewipc.h" +#include "tst_test.h" +#include "tst_safe_sysv_ipc.h" + +#ifdef HAVE_SHMID64_DS_TIME_HIGH + +static void run(void) +{ + struct shmid64_ds buf_ds = { + .shm_atime_high = 0x0A0A, + .shm_dtime_high = 0x0A0A, + .shm_ctime_high = 0x0A0A, + }; + int shmid; + key_t key; + + /* get an IPC resource key */ + key = GETIPCKEY(); + + shmid = shmget(key, SHM_SIZE, IPC_CREAT | IPC_EXCL | SHM_RW); + if (shmid == -1) + tst_brk(TBROK | TERRNO, "couldn't create shared memory segment"); + + TEST(shmctl(shmid, IPC_STAT, (struct shmid_ds *)&buf_ds)); + if (TST_RET == -1) + tst_brk(TFAIL | TTERRNO, "shmctl() failed"); + + if (buf_ds.shm_atime_high || buf_ds.shm_dtime_high || buf_ds.shm_ctime_high) + tst_res(TFAIL, "time_high fields aren't cleared by the kernel"); + else + tst_res(TPASS, "time_high fields cleared by the kernel"); + + SAFE_SHMCTL(shmid, IPC_RMID, NULL); +} + +static struct tst_test test = { + .test_all = run, + .needs_tmpdir = 1, +}; +#else +TST_TEST_TCONF("test requires struct shmid64_ds to have the time_high fields"); +#endif From patchwork Tue Jun 16 10:20:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1310223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=J09vk6dM; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49mPPH3M0bz9sSc for ; Tue, 16 Jun 2020 20:21:23 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 093483C2D0F for ; Tue, 16 Jun 2020 12:21:21 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id 793DD3C2D0B for ; Tue, 16 Jun 2020 12:20:45 +0200 (CEST) Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 37216279906 for ; Tue, 16 Jun 2020 12:20:44 +0200 (CEST) Received: by mail-pf1-x444.google.com with SMTP id z63so8351058pfb.1 for ; Tue, 16 Jun 2020 03:20:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3YJTGb3QxaU9a99jVkwxiAFKCAZb8mdHwOVjnbcBxBc=; b=J09vk6dMX89R3Z2mzs+fnrRpyJ7jMwLx0gx+WJSu5BpOG5c2MBQXGBS5CxcdDRdUZw +VJqg/ndaBlC119p6WIjFznDI1KWLNRAwV9yGzetTyWlmXz673ptyVw50p3DTHxRKauK 0/cS/bJ8dMoOicTaByxGQ0VTBngWJ9YGUMvJfhIPsi9eV/FIMkET5pfZP5kjGystnRpA nMHlYC9JwMox6EBUeJ9gGHKhuwgIEvkoaQ9KUDuPY+QO4qiqFlMOdAFKYZ/7OLGoswH1 ylr8EXsqcS4G3nqFFSCq9hzBKIPUF74VPoDDyiyTiLwt5kqUC+0cvaU9SjUnHkAgpwN8 vOSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3YJTGb3QxaU9a99jVkwxiAFKCAZb8mdHwOVjnbcBxBc=; b=pkmcN4qZRXN2zUAbbSh4rLYU+5QD2OVM68+1sZHUazoHOcYf+jRyKv/vn3Xk2veamU Q7gZGeKwEX8lPXr6kxLWt/Pz63+nQdqmekBDT89ZZMbDg8OndR/Q1X6iUeyC448E6Zm/ dSaq9lh75DW0BsqhZOs6qgchtb6uuTbAl1nZHUh4LPXOyo/PMeW7X8M9rcwZ7Ph4ha43 VFnYYyCLXsuYuFOvJGoKKDMJbwQRUe17RWNA+eSSnzHkCXvmbrIA5dfHo1hd01Vbye7l cWIZGc7BWJ3RX7VRR0OveoRXt1u/s2AqbDOZ/x+yYBC37fULDYo9etvX7nIh5PVhN/rO s/GQ== X-Gm-Message-State: AOAM533gQ1T737BeexXABy6poj5lp5Zj4fs1LNa1VzCR1E5OiPYglOoO JgX4252riYutPAQ3k77tK9Q14num2GI= X-Google-Smtp-Source: ABdhPJz8qPudejrg42TNvg4IrryxayF67B9FrnMQwf/yejwHm0y2u+Y0h+qR+njLd2SDq8+rIXFBvw== X-Received: by 2002:aa7:8283:: with SMTP id s3mr1512878pfm.90.1592302842255; Tue, 16 Jun 2020 03:20:42 -0700 (PDT) Received: from localhost ([122.172.119.132]) by smtp.gmail.com with ESMTPSA id w18sm6498206pgj.31.2020.06.16.03.20.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2020 03:20:41 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 16 Jun 2020 15:50:23 +0530 Message-Id: <7616a6fa4f1502dde4417d33aa88836c8020419e.1592302358.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH V2 5/6] include: Add declaration of struct msqid64_ds X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot , arnd@arndb.de, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This adds declaration of struct msqid64_ds, which will be used by following patches. Signed-off-by: Viresh Kumar --- configure.ac | 1 + include/lapi/msgbuf.h | 306 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 307 insertions(+) create mode 100644 include/lapi/msgbuf.h diff --git a/configure.ac b/configure.ac index f1ee98b23cbe..05032d1cfd8f 100644 --- a/configure.ac +++ b/configure.ac @@ -153,6 +153,7 @@ AC_CHECK_TYPES([struct iovec],,,[#include ]) AC_CHECK_TYPES([struct ipc64_perm],,,[#include ]) AC_CHECK_TYPES([struct semid64_ds],,,[#include ]) AC_CHECK_TYPES([struct shmid64_ds],,,[#include ]) +AC_CHECK_TYPES([struct msqid64_ds],,,[#include ]) AC_CHECK_TYPES([struct mmsghdr],,,[ #define _GNU_SOURCE diff --git a/include/lapi/msgbuf.h b/include/lapi/msgbuf.h new file mode 100644 index 000000000000..779362c4f07a --- /dev/null +++ b/include/lapi/msgbuf.h @@ -0,0 +1,306 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Linaro Limited. All rights reserved. + * Author: Viresh Kumar + */ + +#ifndef IPC_MSGBUF_H +#define IPC_MSGBUF_H + +#include +#include +#include "tst_timer.h" +#include "ipcbuf.h" + +#ifndef HAVE_MSQID64_DS + +#if defined(__mips__) +#define HAVE_MSQID64_DS + +#if defined(__arch64__) +/* + * The msqid64_ds structure for the MIPS architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous unsigned long values + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; + long msg_stime; /* last msgsnd time */ + long msg_rtime; /* last msgrcv time */ + long msg_ctime; /* last change time */ + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; +#elif defined (__MIPSEB__) +#define HAVE_MSQID64_DS_TIME_HIGH +struct msqid64_ds { + struct ipc64_perm msg_perm; + unsigned long msg_stime_high; + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_rtime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_ctime_high; + unsigned long msg_ctime; /* last change time */ + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; +#elif defined (__MIPSEL__) +#define HAVE_MSQID64_DS_TIME_HIGH +struct msqid64_ds { + struct ipc64_perm msg_perm; + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_stime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_rtime_high; + unsigned long msg_ctime; /* last change time */ + unsigned long msg_ctime_high; + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; +#endif + +#endif /* __mips__ */ + +#if defined(__hppa__) +#define HAVE_MSQID64_DS +/* + * The msqid64_ds structure for parisc architecture, copied from sparc. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; +#if __BITS_PER_LONG == 64 + long msg_stime; /* last msgsnd time */ + long msg_rtime; /* last msgrcv time */ + long msg_ctime; /* last change time */ +#else +#define HAVE_MSQID64_DS_TIME_HIGH + unsigned long msg_stime_high; + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_rtime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_ctime_high; + unsigned long msg_ctime; /* last change time */ +#endif + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused1; + unsigned long __unused2; +}; + +#endif /* __hppa__ */ + +#if defined(__powerpc__) || defined(__powerpc64__) +#define HAVE_MSQID64_DS +/* + * The msqid64_ds structure for the PowerPC architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; +#ifdef __powerpc64__ + long msg_stime; /* last msgsnd time */ + long msg_rtime; /* last msgrcv time */ + long msg_ctime; /* last change time */ +#else +#define HAVE_MSQID64_DS_TIME_HIGH + unsigned long msg_stime_high; + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_rtime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_ctime_high; + unsigned long msg_ctime; /* last change time */ +#endif + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif /* defined(__powerpc__) || defined(__powerpc64__) */ + +#if defined(__sparc__) +#define HAVE_MSQID64_DS +/* + * The msqid64_ds structure for sparc64 architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ +struct msqid64_ds { + struct ipc64_perm msg_perm; +#if defined(__arch64__) + long msg_stime; /* last msgsnd time */ + long msg_rtime; /* last msgrcv time */ + long msg_ctime; /* last change time */ +#else +#define HAVE_MSQID64_DS_TIME_HIGH + unsigned long msg_stime_high; + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_rtime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_ctime_high; + unsigned long msg_ctime; /* last change time */ +#endif + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused1; + unsigned long __unused2; +}; + +#endif /* __sparc__ */ + +#if defined(__x86_64__) && defined(__ILP32__) +#define HAVE_MSQID64_DS +/* + * The msqid64_ds structure for x86 architecture with x32 ABI. + * + * On x86-32 and x86-64 we can just use the generic definition, but + * x32 uses the same binary layout as x86_64, which is differnet + * from other 32-bit architectures. + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; + __kernel_long_t msg_stime; /* last msgsnd time */ + __kernel_long_t msg_rtime; /* last msgrcv time */ + __kernel_long_t msg_ctime; /* last change time */ + __kernel_ulong_t msg_cbytes; /* current number of bytes on queue */ + __kernel_ulong_t msg_qnum; /* number of messages in queue */ + __kernel_ulong_t msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + __kernel_ulong_t __unused4; + __kernel_ulong_t __unused5; +}; + +#endif /* defined(__x86_64__) && defined(__ILP32__) */ + +#if defined(__xtensa__) +#define HAVE_MSQID64_DS +/* + * The msqid64_ds structure for the Xtensa architecture. + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; +#ifdef __XTENSA_EB__ +#define HAVE_MSQID64_DS_TIME_HIGH + unsigned long msg_stime_high; + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_rtime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_ctime_high; + unsigned long msg_ctime; /* last change time */ +#elif defined(__XTENSA_EL__) +#define HAVE_MSQID64_DS_TIME_HIGH + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_stime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_rtime_high; + unsigned long msg_ctime; /* last change time */ + unsigned long msg_ctime_high; +#else +# error processor byte order undefined! +#endif + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif /* __xtensa__ */ + +#ifndef HAVE_MSQID64_DS +/* + * generic msqid64_ds structure. + * + * Note extra padding because this structure is passed back and forth + * between kernel and user space. + * + * msqid64_ds was originally meant to be architecture specific, but + * everyone just ended up making identical copies without specific + * optimizations, so we may just as well all use the same one. + * + * 64 bit architectures use a 64-bit long time field here, while + * 32 bit architectures have a pair of unsigned long values. + * On big-endian systems, the lower half is in the wrong place. + * + * Pad space is left for: + * - 2 miscellaneous 32-bit values + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; +#if __BITS_PER_LONG == 64 + long msg_stime; /* last msgsnd time */ + long msg_rtime; /* last msgrcv time */ + long msg_ctime; /* last change time */ +#else +#define HAVE_MSQID64_DS_TIME_HIGH + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_stime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_rtime_high; + unsigned long msg_ctime; /* last change time */ + unsigned long msg_ctime_high; +#endif + unsigned long msg_cbytes; /* current number of bytes on queue */ + unsigned long msg_qnum; /* number of messages in queue */ + unsigned long msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + unsigned long __unused4; + unsigned long __unused5; +}; + +#endif /* msqid64_ds */ + +#endif /* HAVE_MSQID64_DS */ + +#endif /* IPC_MSGBUF_H */ From patchwork Tue Jun 16 10:20:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1310224 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=TYaeWPj8; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49mPPW5pYlz9sSc for ; Tue, 16 Jun 2020 20:21:35 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2AFF73C5FBF for ; Tue, 16 Jun 2020 12:21:33 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 3CDD73C2D07 for ; Tue, 16 Jun 2020 12:20:47 +0200 (CEST) Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 8536A1BD2118 for ; Tue, 16 Jun 2020 12:20:46 +0200 (CEST) Received: by mail-pg1-x541.google.com with SMTP id u128so2124588pgu.13 for ; Tue, 16 Jun 2020 03:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C79LupuzJfAylHY/PoPF0aGRQrANOqNq/v2t8YecEUM=; b=TYaeWPj8kY+JEmDxLLqGMtjj3e/K86WW+9F3rrsqvBfkxYTeavhMwsKsh5uYWKY518 DXAKMZZoKmUUiWXmdLZS53nFBj+UG+2652O6vFBoFq+PpExD9E0DkaFDLxczGkJDpsj0 KBvJKy511qLQWWXw9ejwYhaIEJbb8iaKMcOfTh6/7sA53/JR5a7yxk+J0yV3WQJO9IjQ Pw+rLU8Is46o1VBU1x/pjjaT+EOQm+ESj1OhdmQx2f2UaQ9XMKMpEI5XAKUlKxIajt2u 0o6VxOvb/Ytkw2Gwy/ps6/4jGHpYTgXajxy2HlsycVrIGCgDRbYJz2sO1O5tdSyRGKLX 38Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C79LupuzJfAylHY/PoPF0aGRQrANOqNq/v2t8YecEUM=; b=FrVCJR4CQszn+ZFJqU0Lgi0FD0DhzytjGiMv8l6TfAYzenZwdaNX6dipRyJNnvYcMd P9ZP/GfuEYNfE55/PsFlb6tQjAvZYNK26YvFsDZgg33rFW+wEXd8yi3hTCgIgq34c2Ol DhSFTBwY4O0+VVTBFYd1H32G6V4nFgdtiA4ufrzDYOeWVxm0QNeYEOwxRH13nmE5wUPm E0EH36Z7DDnQnuOOG3PQlt+ZIDSOedtu5I9ljaRrvE+q5ak7+WFi3S/zcowRldHsUgIe 9P9cYowIFsuoTqx5PJlRx8WWR0Omk0KmEHs1wioMZj21v4wa2zq2uzrUg/S5pM5QrYyz jS0g== X-Gm-Message-State: AOAM533iSJhyj1CHVfrsEei1SZqw+mY2tHcf8cDEeSgQ0iZfpUA1tbAe 1nTzMDJePubirJjP62/GXw5jilL6bBU= X-Google-Smtp-Source: ABdhPJzNnFyrK+RKr52L8fbrdJ3god7nMpeQZjxyE7JF2UnJVOOFmTFUhgS+1YT67ku3pDV1y7BY6g== X-Received: by 2002:a63:1114:: with SMTP id g20mr1535815pgl.3.1592302844753; Tue, 16 Jun 2020 03:20:44 -0700 (PDT) Received: from localhost ([122.172.119.132]) by smtp.gmail.com with ESMTPSA id l83sm16861101pfd.150.2020.06.16.03.20.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2020 03:20:44 -0700 (PDT) From: Viresh Kumar To: ltp@lists.linux.it Date: Tue, 16 Jun 2020 15:50:24 +0530 Message-Id: <64c024464dbc063afebdc76c8f691380067873b9.1592302358.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH V2 6/6] syscalls: msgctl: Add new test to verify the _time_high fields X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot , arnd@arndb.de, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The _time_high fields must be reset by the kernel, add a test to verify that. Suggested-by: Arnd Bergmann Signed-off-by: Viresh Kumar --- runtest/syscalls | 1 + runtest/syscalls-ipc | 1 + .../kernel/syscalls/ipc/msgctl/.gitignore | 1 + .../kernel/syscalls/ipc/msgctl/msgctl05.c | 48 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 testcases/kernel/syscalls/ipc/msgctl/msgctl05.c diff --git a/runtest/syscalls b/runtest/syscalls index f8b2277e0eda..ee7e2a0d217d 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -797,6 +797,7 @@ msgctl01 msgctl01 msgctl02 msgctl02 msgctl03 msgctl03 msgctl04 msgctl04 +msgctl05 msgctl05 msgstress01 msgstress01 msgstress02 msgstress02 msgstress03 msgstress03 diff --git a/runtest/syscalls-ipc b/runtest/syscalls-ipc index 5ba3b1449a6c..c3a35896c5a8 100644 --- a/runtest/syscalls-ipc +++ b/runtest/syscalls-ipc @@ -2,6 +2,7 @@ msgctl01 msgctl01 msgctl02 msgctl02 msgctl03 msgctl03 msgctl04 msgctl04 +msgctl05 msgctl05 msgstress01 msgstress01 msgstress02 msgstress02 msgstress03 msgstress03 diff --git a/testcases/kernel/syscalls/ipc/msgctl/.gitignore b/testcases/kernel/syscalls/ipc/msgctl/.gitignore index f179f2606a3e..0157f4611bdf 100644 --- a/testcases/kernel/syscalls/ipc/msgctl/.gitignore +++ b/testcases/kernel/syscalls/ipc/msgctl/.gitignore @@ -2,4 +2,5 @@ /msgctl02 /msgctl03 /msgctl04 +/msgctl05 /msgctl12 diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl05.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl05.c new file mode 100644 index 000000000000..cd2643bc1ead --- /dev/null +++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl05.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Cross verify the _high fields being set to 0 by the kernel. + */ +#include +#include "lapi/msgbuf.h" +#include "libnewipc.h" +#include "tst_test.h" +#include "tst_safe_sysv_ipc.h" + +#ifdef HAVE_MSQID64_DS_TIME_HIGH + +static void run(void) +{ + struct msqid64_ds buf_ds = { + .msg_stime_high = 0x0A0A, + .msg_rtime_high = 0x0A0A, + .msg_ctime_high = 0x0A0A, + }; + int msqid; + key_t key; + + key = GETIPCKEY(); + + msqid = SAFE_MSGGET(key, IPC_CREAT | IPC_EXCL | MSG_RW | 0600); + + TEST(msgctl(msqid, IPC_STAT, (struct msqid_ds *)&buf_ds)); + if (TST_RET == -1) + tst_brk(TFAIL | TTERRNO, "msqctl() failed"); + + if (buf_ds.msg_stime_high || buf_ds.msg_rtime_high || buf_ds.msg_ctime_high) + tst_res(TFAIL, "time_high fields aren't cleared by the kernel"); + else + tst_res(TPASS, "time_high fields cleared by the kernel"); + + SAFE_MSGCTL(msqid, IPC_RMID, NULL); +} + +static struct tst_test test = { + .test_all = run, + .needs_tmpdir = 1, +}; +#else +TST_TEST_TCONF("test requires struct msqid64_ds to have the time_high fields"); +#endif