All of lore.kernel.org
 help / color / mirror / Atom feed
From: C Smith <csmithquestions@gmail.com>
To: Xenomai List <xenomai@xenomai.org>
Subject: Re: rtcansend 32-bit
Date: Tue, 2 Nov 2021 15:57:13 -0700	[thread overview]
Message-ID: <CA+K1mPE4d9qQ2-tT+rDGBR4v__vzrXu2736+JFADco8a6Y7xLQ@mail.gmail.com> (raw)
In-Reply-To: <9a0553a5-aa37-a089-54e8-45a59ebf1095@siemens.com>

I added some printf/printk to rtcansend.c as well as rtcan_raw.c:

rtcan_raw.c:
    /* Check size of buffer */
    if (iov->iov_len != sizeof(can_frame_t)) {
            printk("rtcan_raw.c, 850: sizeof(can_frame_t): %ld\n",
                   sizeof(can_frame_t));
                printk("rtcan_raw.c, 852: iov->iov_len: %ld\n",
iov->iov_len);
            return -EMSGSIZE;
    }

when running rtcansend (32-bit compile, which fails with EMSGSIZE):
        [root@pc can]# /usr/xenomai/bin/rtcansend rtcan0 -s 0xde 0xad
        sizeof(can_frame_t): 16
        send: Message too long

        [root@pc can]# dmesg
        [11275.197125] rtcan_raw.c, 850: sizeof(can_frame_t): 16
        [11275.197133] rtcan_raw.c, 852: iov->iov_len: 34494267600

when running rtcansend (64-bit compile, sends out can msg OK):
        [root@pc can]# /usr/xenomai/bin/rtcansend rtcan0 -s 0xde 0xad
        sizeof(can_frame_t): 16

        [root@pc can]# dmesg
        [12476.571032] rtcan_raw.c, 850: sizeof(can_frame_t): 16
        [12476.571040] rtcan_raw.c, 852: iov->iov_len: 16

It looks like the struct user_msghdr *msg passed into rtcan_raw_sendmsg()
is corrupt.
I'm using Xenomai 3.1, with kernel 4.19.989 x86_64
-C Smith

On Tue, Nov 2, 2021 at 12:11 PM Jan Kiszka <jan.kiszka@siemens.com> wrote:

> On 02.11.21 19:57, C Smith via Xenomai wrote:
> > I ran into a problem wherein my real-time Xenomai 32-bit app
> > fails on the socket operations of the 64-bit CAN driver.
> > My real-time userspace app is Cobalt x86, compiled -m32.
> >
> > When I try the Xenomai rtcansend.c sample app compiled 32-bit, I get the
> > same error :
> >
> > [root@pc can]# /usr/xenomai/bin/rtcansend rtcan0 --verbose
> > --identifier=0x123 0xde 0xad
> > send: Message too long
> >
> > Looking at rtcansend.c. The call to sendto is failing and returns
> 'Message
> > too long' here:
> > ret = sendto(s, (void *)&frame, sizeof(can_frame_t), 0,
> > (struct sockaddr *)&to_addr, sizeof(to_addr));
> >
> > Here is how I configured Xenomai for 32-bit when I built it:
> > ./configure --host=i686-linux CFLAGS="-m32 -D_FILE_OFFSET_BITS=64"
> > LDFLAGS=-m32 host_alias=i686-linux
> >
> > But note that if I compile both Xenomai and rtcansend.c 64-bit,
> everything
> > works fine.
> >
> > So how can 32-bit Xeno apps use the 64-bit CAN driver ?
> >
>
> We possibly have compat ABI issue here: The Xenomai core can handle
> 32-bit calls of sendto (sendmsg internally) into 64-bit kernel, but
> maybe there is something beyond that interpreted by the CAN driver that
> is not aware of 32 vs. 64 bit userland.
>
> I suspect sizeof(can_frame_t) varies, though I don't see why yet. Could
> you debug that, instrument kernel/drivers/can/rtcan_raw.c as well as the
> userspace code?
>
> The other reason for EMSGSIZE would be msg_iovlen != 1, but that would
> mean we have an issue in the generic compat sendmsg code, and that is
> less likely.
>
> Jan
>
> --
> Siemens AG, T RDA IOT
> Corporate Competence Center Embedded Linux
>

  reply	other threads:[~2021-11-02 22:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02 18:57 rtcansend 32-bit C Smith
2021-11-02 19:11 ` Jan Kiszka
2021-11-02 22:57   ` C Smith [this message]
2021-11-03  6:59     ` Jan Kiszka
2021-11-03 10:46       ` Jan Kiszka
2021-11-03 11:09         ` Bezdeka, Florian
2021-11-04  6:49           ` C Smith
2021-11-04  8:05             ` Bezdeka, Florian
2021-11-05  7:09               ` C Smith
2021-11-05  8:14                 ` Jan Kiszka
2021-11-05  8:25                   ` Bezdeka, Florian
2021-11-05 18:14                     ` C Smith
2021-11-05 18:21                       ` Jan Kiszka

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=CA+K1mPE4d9qQ2-tT+rDGBR4v__vzrXu2736+JFADco8a6Y7xLQ@mail.gmail.com \
    --to=csmithquestions@gmail.com \
    --cc=xenomai@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.