linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	y2038 Mailman List <y2038@lists.linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	me@zv.io
Subject: Re: [PATCH v5 6/8] media: v4l2-core: fix v4l2_buffer handling for time64 ABI
Date: Sun, 15 Dec 2019 18:26:30 +0100	[thread overview]
Message-ID: <bfc18778-0777-ad49-619b-39e1b9b536f3@xs4all.nl> (raw)
In-Reply-To: <CAK8P3a1-xLUn368Lajia1=2GEXa92srQ2s9wH--MrRHj+kSTtQ@mail.gmail.com>

On 12/14/19 10:44 PM, Arnd Bergmann wrote:
> On Sat, Dec 14, 2019 at 12:27 PM Hans Verkuil <hverkuil@xs4all.nl> wrote:
>>
>> On 12/13/19 4:32 PM, Hans Verkuil wrote:
>>>>> I am unable to test with musl since v4l2-ctl and v4l2-compliance are C++ programs,
>>>>> and there doesn't appear to be an easy way to compile a C++ program with musl.
>>>>>
>>>>> If you happen to have a test environment where you can compile C++ with musl,
>>>>> then let me know and I can give instructions on how to run the compliance tests.
>>>>>
>>>>> If you can't test that, then I can merge this regardless, and hope for the best
>>>>> once the Y2038 fixes end up in glibc. But ideally I'd like to have this tested.
>>>>
>>>> I've heard good things about the prebuilt toolchains from http://musl.cc/.
>>>> These seems to come with a libstdc++, but I have not tried that myself.
>>>
>>> I'll see if I can give those a spin, but if I can't get it to work quickly,
>>> then I don't plan on spending much time on it.
>>
>> I managed to build v4l2-ctl/compliance with those toolchains, but they seem to be
>> still using a 32-bit time_t.
>>
>> Do I need to get a specific version or do something special?
> 
> My mistake: only musl-1.2.0 and up have 64-bit time_t, but this isn't released
> yet. According to https://wiki.musl-libc.org/roadmap.html, the release
> was planned
> for last month, no idea how long it will take.
> 
> It appears that a snapshot build at
> http://more.musl.cc/7.5.0/x86_64-linux-musl/i686-linux-musl-native.tgz
> is new enough to have 64-bit time_t (according to include/bits/alltypes.h),
> but this is a month old as well, so it may have known bugs.

Ah, great, that worked, after applying the patch below.

Both struct v4l2_buffer32 and v4l2_event32 need to be packed, otherwise you would
get an additional 4 bytes since the 64 bit compiler wants to align the 8 byte tv_secs
to an 8 byte boundary. But that's not what the i686 compiler does.

If I remember correctly, packed is only needed for CONFIG_X86_64.

With these changes (plus a bunch of fixes for v4l-utils) I was able to do full
compliance tests for 64-bit, 32-bit time32 under x86_64, 32-bit time64 under x86_64,
time32 under i686 and time64 under i686.

Arnd, if you can post a v6 with the previous fixes and this fix included, then
I'll make a pull request for this for kernel 5.6.

Regards,

	Hans


Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 3bbf47d950e0..c01492cf6160 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -492,7 +492,11 @@ struct v4l2_buffer32 {
 	__u32			length;
 	__u32			reserved2;
 	__s32			request_fd;
+#ifdef CONFIG_X86_64
+} __attribute__ ((packed));
+#else
 };
+#endif

 struct v4l2_buffer32_time32 {
 	__u32			index;
@@ -1280,7 +1284,7 @@ struct v4l2_event32 {
 	struct __kernel_timespec	timestamp;
 	__u32				id;
 	__u32				reserved[8];
-};
+} __attribute__ ((packed));

 struct v4l2_event32_time32 {
 	__u32				type;

  reply	other threads:[~2019-12-15 17:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 16:18 [PATCH v5 0/8] y2038 safety in v4l2 Arnd Bergmann
2019-11-26 16:18 ` [PATCH v5 1/8] media: documentation: fix video_event description Arnd Bergmann
2019-11-26 16:18 ` [PATCH v5 2/8] media: v4l2: abstract timeval handling in v4l2_buffer Arnd Bergmann
2019-11-26 16:18 ` [PATCH v5 3/8] media: v4l2-core: compat: ignore native command codes Arnd Bergmann
2019-11-26 16:18 ` [PATCH v5 4/8] media: v4l2-core: split out data copy from video_usercopy Arnd Bergmann
2019-11-26 16:18 ` [PATCH v5 5/8] media: v4l2-core: fix VIDIOC_DQEVENT for time64 ABI Arnd Bergmann
2019-11-26 16:18 ` [PATCH v5 6/8] media: v4l2-core: fix v4l2_buffer handling " Arnd Bergmann
2019-12-12 15:43   ` Hans Verkuil
2019-12-13 15:08     ` Arnd Bergmann
2019-12-13 15:32       ` Hans Verkuil
2019-12-13 15:38         ` Arnd Bergmann
2019-12-14 11:27         ` Hans Verkuil
2019-12-14 21:44           ` Arnd Bergmann
2019-12-15 17:26             ` Hans Verkuil [this message]
2019-12-16  9:29               ` Arnd Bergmann
2019-12-16 10:28                 ` Hans Verkuil
2019-12-19 23:26             ` Zach van Rijn
2019-11-26 16:18 ` [PATCH v5 7/8] media: v4l2-core: fix compat VIDIOC_DQEVENT " Arnd Bergmann
2019-11-26 16:18 ` [PATCH v5 8/8] media: v4l2-core: fix compat v4l2_buffer handling " Arnd Bergmann
2019-11-26 19:55 ` [PATCH v5.1 4/8] media: v4l2-core: split out data copy from video_usercopy Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bfc18778-0777-ad49-619b-39e1b9b536f3@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=me@zv.io \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).